Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created May 4, 2011 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/955325 to your computer and use it in GitHub Desktop.
Save jutememo/955325 to your computer and use it in GitHub Desktop.
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