Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created March 5, 2012 09:07
Show Gist options
  • Save dtchepak/1977577 to your computer and use it in GitHub Desktop.
Save dtchepak/1977577 to your computer and use it in GitHub Desktop.
folding over two lists
fold2r :: (a -> b -> c -> c) -> c -> [a] -> [b] -> c
fold2r f seed (a:as) (b:bs) = f a b (fold2r f seed as bs)
fold2r _ seed _ _ = seed
zipWithFold2r f = fold2r (\a b c -> (f a b):c) []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment