Use pattern matching instead of case
This commit is contained in:
parent
108e582b35
commit
37f974ef02
@ -27,9 +27,8 @@ rpn = foldM parse [] . words >=> return . head where
|
||||
parse (y:x:xs) (flip lookup dyad -> Just f) = Right (f x y : xs)
|
||||
parse (x:xs) (flip lookup monad -> Just f) = Right (f x : xs)
|
||||
parse xs (flip lookup nilad -> Just k) = Right (k : xs)
|
||||
parse xs x = case readMaybe x of
|
||||
Just x -> Right (x : xs)
|
||||
Nothing -> Left "syntax error"
|
||||
parse xs (readMaybe -> Just x) = Right (x : xs)
|
||||
parse xs _ = Left "syntax error"
|
||||
|
||||
|
||||
-- dyadic functions
|
||||
|
Loading…
Reference in New Issue
Block a user