Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
foldr2 _ z [] k = k z
foldr2 f z (x:xs) k = foldr2 f z xs $ \y -> k $ f x y
main = do print $ foldr2 (+) 0 [1..10] id
print $ foldr2 (+) 0 [1..10] (* 2)
print $ foldr2 (++) [] [[1,2],[3,4],[],[5,6]] id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment