Skip to content

Instantly share code, notes, and snippets.

@karbassi
Created February 13, 2010 00:42
Show Gist options
  • Save karbassi/303153 to your computer and use it in GitHub Desktop.
Save karbassi/303153 to your computer and use it in GitHub Desktop.
function foldl(f, z, xs) {
return xs.length === 0 ? z : foldl(f, f(z, xs[0], xs.slice(1)));
}
function foldr(f, z, xs) {
return xs.length === 0 ? z : f(xs[0], foldr(f, z, xs.slice(1)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment