From e2278ad89203deff48b7a1d82d33a8f9e4b565cf Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Thu, 26 Feb 2015 23:51:05 +0100 Subject: [PATCH] Skip empty lines --- RPN.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RPN.hs b/RPN.hs index 71536af..98a8620 100644 --- a/RPN.hs +++ b/RPN.hs @@ -8,10 +8,10 @@ main :: IO () main = io (show . rpn) io :: (String -> String) -> IO () -io f = interact (unlines . map f . lines) +io f = interact (unlines . map f . filter (not . null) . lines) rpn :: String -> Either String Double -rpn = return . head <=< foldM parse [] . words +rpn = foldM parse [] . words >=> return . head parse :: [Double] -> String -> Either String [Double] parse (y:x:xs) (flip lookup dyad -> Just f) = Right (f x y : xs)