3 ms·
So, haskell version may be little shorter main = interact $ unlines. map (show.calc) .lines calc :: String -> [Float] calc = foldl f [] . words wher
by passed_By 8y ago
So, haskell version may be little shorter
main = interact $ unlines. map (show.calc) .lines
calc :: String -> [Float]
calc = foldl f [] . words
where
f (x:y:zs) "+" = (y + x):zs
f (x:y:zs) "-" = (y - x):zs
f (x:y:zs) "*" = (y * x):zs
f (x:y:zs) "/" = (y / x):zs
f xs y = read y : xs