Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created May 4, 2011 14:50
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/955345 to your computer and use it in GitHub Desktop.
Save jutememo/955345 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 ->
if x == [] then [] else k $ f x y
main = do print $ foldr2' (++) [] [[1,2],[3,4],[5,6]] id
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