$ echo -e '1 2 3\n4 5 6' | runhaskell Main.hs
[[1,2,3],[4,5,6]]
Last active
November 25, 2020 07:50
-
-
Save sroccaserra/6a535c65f142aab677f853d069565e25 to your computer and use it in GitHub Desktop.
Read lines from file lazily in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = do | |
lines <- fmap lines getContents | |
print $ process lines | |
process :: [String] -> [[Int]] | |
process = map processLine | |
processLine :: String -> [Int] | |
processLine = map read . words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment