diff --git a/hsilop.hs b/hsilop.hs index d52ce2e..ada60b5 100644 --- a/hsilop.hs +++ b/hsilop.hs @@ -18,7 +18,8 @@ io f = interact (unlines . map f . filter (not . null) . lines) result :: Either String Double -> String result (Left err) = "Ꞥ∘ " ++ err result (Right x) = printf ("ꟼ∘ " ++ format) x where - format = if ceiling x == floor x then "%.0f" else "%.10f" + format | ceiling x == floor x = "%.0f" + | otherwise = "%.10f" -- Solve a RPN expression @@ -28,7 +29,7 @@ rpn = foldM parse [] . words >=> return . head where parse (x:xs) (flip lookup monad -> Just f) = Right (f x : xs) parse xs (flip lookup nilad -> Just k) = Right (k : xs) parse xs (readMaybe -> Just x) = Right (x : xs) - parse xs _ = Left "syntax error" + parse _ _ = Left "syntax error" -- dyadic functions