Evaluates well-formed reverse polish notation expressions (http://en.wikipedia.org/wiki/Reverse_Polish_notation).
Strings with tokens separated by single spaces. Tokens are operators or operands. Operators are +, -, * or /. Operands are integers or floats (e.g. 7, 3.23, -1e9).
The value of the evaluated expression.
"1 1 +" -> 2
"5 8 -" -> -3
"2 3 7 + -" -> -8
"5 3 * 5 +" -> 20
Using the ideas outlined above, the eval-less version now is under 140 bytes too (138 bytes):
function(a,b){return(b=[])[a.replace(/\S+/g,function(c,d){b.push(+c==c?+c:(d=b.pop(a=b.pop()),c=='+'?d+a:c=='-'?d-a:c=='*'?d*a:d/a))}),0]}
Thanks everyone.