Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d0536f6 commit 29373bdCopy full SHA for 29373bd
2018/01_1/haskell/appositum.hs
@@ -8,13 +8,10 @@ parse :: String -> Int -> Int
8
parse ('+':n) = (+ readInt n)
9
parse ('-':n) = subtract (readInt n)
10
11
-loop :: Int -> [String] -> Int
12
-loop acc lst =
13
- foldl' (flip ($)) acc (map parse lst)
14
-
15
main :: IO ()
16
main = do
17
args <- getArgs
18
case args of
19
[] -> putStrLn "Usage: ./appositum input.txt"
20
- (arg:_) -> readFile arg >>= print . loop 0 . lines
+ (arg:_) -> readFile arg
+ >>= print . foldl' (flip ($)) 0 . map parse . lines
0 commit comments