Prefix Notation Evaluation

Published by Werdna in

Create a function that takes a mathematical expression in prefix notation as a string and evaluates the expression.

Examples

prefix("+ 5 4") ➞ 9

prefix("* 12 2") ➞ 24

prefix("+ -10 10") ➞ 0

Notes

  • The mathematical expression is valid.
  • Check the Resources.
Watch a quick demo on how Edabit works.