Created
October 24, 2018 12:39
-
-
Save tmountain/401b152ff964b86990b88a2061d52d4a to your computer and use it in GitHub Desktop.
Lazy vs Non-Lazy Folds
This file contains hidden or 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
-- lazy vs non-lazy folds | |
-- works on infinite lists | |
take 5 $ foldr (:) [] [1..] | |
-- infinite loop | |
cons' = flip (:) -- acc is first arg to foldl | |
take 5 $ foldl cons' [] [1..] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment