Last active
August 29, 2015 14:23
-
-
Save timhuff/ca1366cb9b954d1b48d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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