Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29373bd

Browse files
committed
Simplify day 1
1 parent d0536f6 commit 29373bd

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

2018/01_1/haskell/appositum.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ parse :: String -> Int -> Int
88
parse ('+':n) = (+ readInt n)
99
parse ('-':n) = subtract (readInt n)
1010

11-
loop :: Int -> [String] -> Int
12-
loop acc lst =
13-
foldl' (flip ($)) acc (map parse lst)
14-
1511
main :: IO ()
1612
main = do
1713
args <- getArgs
1814
case args of
1915
[] -> putStrLn "Usage: ./appositum input.txt"
20-
(arg:_) -> readFile arg >>= print . loop 0 . lines
16+
(arg:_) -> readFile arg
17+
>>= print . foldl' (flip ($)) 0 . map parse . lines

0 commit comments

Comments
 (0)