Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
prefixString = "* + 2 3 4"
evaluatePrefix = (prefix)->
operator = prefix.shift()
leftValue = if isNaN parseFloat prefix[0] then evaluatePrefix prefix else prefix.shift()
rightValue = if isNaN parseFloat prefix[0] then evaluatePrefix prefix else prefix.shift()
eval leftValue+operator+rightValue
prefix = prefixString.split ' '
console.log evaluatePrefix prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.