Skip to content

Instantly share code, notes, and snippets.

@tonymorris

tonymorris/Fold.hs

Created Sep 18, 2012
Embed
What would you like to do?
Anna meets Cata
foldr ::
(a -> b -> b)
-> b
-> [a]
-> b
-- same:
foldr ::
((a, b) -> b)
-> b
-> [a]
-> b
-- same:
foldr ::
((a, b) -> b, b)
-> [a]
-> b
-- same:
foldr ::
(Maybe (a, b) -> b)
-> [a]
-> b
-- reverse the arrows:
unfoldr ::
(b -> Maybe (a, b))
-> b
-> [a]
-- The End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment