RosettaCodeData/Task/Parsing-RPN-calculator-algorithm/Haskell/parsing-rpn-calculator-algorithm-3.hs

8 lines
204 B
Haskell
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import Control.Monad (foldM)
calcRPNIO :: String -> IO [Double]
calcRPNIO = foldM (verbose interprete) [] . words
verbose f s x = write (x ++ "\t" ++ show res ++ "\n") >> return res
where res = f s x