Created
July 20, 2015 07:04
-
-
Save shigemk2/6b933009bb52af37f9c6 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
| import Data.List.Split | |
| rpn str = rpnPrime (splitOn " " str) [] | |
| rpnPrime ("+":t) (y:x:zs) = rpnPrime t $ x + y:zs | |
| rpnPrime (n:t) zs = rpnPrime t $ read n:zs | |
| rpnPrime _ (x:xs) = x | |
| main = do | |
| print $ rpn "1" | |
| print $ rpn "1 2 +" | |
| print $ rpn "1 2 3 + +" | |
| print $ rpn "1 2 + 3 +" | |
| print $ rpn "1 2 + 3 4 + +" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment