summary refs log tree commit diff
path: root/1
diff options
context:
space:
mode:
Diffstat (limited to '1')
-rw-r--r--1/2.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/1/2.hs b/1/2.hs
index dd932d5..a5ba754 100644
--- a/1/2.hs
+++ b/1/2.hs
@@ -8,9 +8,10 @@ import System.Environment
 digits = ["one","two","three","four","five","six","seven","eight","nine"]
 
 parse [] = (mempty,mempty)
-parse l@(x:xs) = case findIndex (`isPrefixOf` l) digits of
-  Just i -> f (Just $ i+1) <> parse xs
-  Nothing -> f (readMaybe [x]) <> parse xs
+
+parse l@(x:xs)
+  | Just i <- findIndex (`isPrefixOf` l) digits = f (Just $ i+1) <> parse xs
+  | otherwise = f (readMaybe [x]) <> parse xs
   where
     f = (,) . First <*> Last