Last active
December 13, 2018 17:48
-
-
Save thealmarty/c70c020e5b41e28ca5e37e66d49a1482 to your computer and use it in GitHub Desktop.
Anamorphisms example in Haskell
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
--Import Data.List so that we can use the unfoldr function. | |
import Data.List | |
--p and g are combined into one function which you input to unfoldr in Haskell: | |
example = unfoldr (\x -> if x > 9 then Nothing else Just (x, x+1)) | |
--Print out results of (example 7) and (example 0). | |
main = do | |
print (example 7) | |
print (example 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See my blog post for further explanation.