Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
data List a = Nil
| Cons a (List a)
deriving Show
xs = Cons 1 (Cons 2 (Cons 3 Nil))
reduceList f z Nil = z
reduceList f z (Cons x xs) = f x (reduceList f z xs)
idList = reduceList Cons Nil
mapList f = reduceList (Cons . f) Nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment