docs: def evaluate_postfix(tokens):
      """
      Given a list of evaluatable tokens in postfix format,
      calculate a solution.
      """
      stack = []
  
      for token in tokens:
          total = None
  
          if is_int(token) or is_float(token) or is_constant(token):
              stack.append(token)
          elif is_unary(token):
              a = stack.pop()
              total = mathwords.UNARY_FUNCTIONS[token](a)
          elif len(stack):
              b = stack.pop()
              a = stack.pop()
              if token == '+':
                  total = a + b
              elif token == '-':
                  total = a - b
              elif token == '*':
                  total = a * b
              elif token == '^':
                  total = a ** b
              elif token == '/':
                  if Decimal(str(b)) == 0:
                      total = 'undefined'
                  else:
                      total = Decimal(str(a)) / Decimal(str(b))
              else:
                  raise PostfixTokenEvaluationException(
                      'Unknown token {}'.format(token)
                  )
  
          if total is not None:
              stack.append(total)
  
      # If the stack is empty the tokens could not be evaluated
      if not stack:
          raise PostfixTokenEvaluationException(
              'The postfix expression resulted in an empty stack'
          )
  
      return stack.pop()