Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewharmellaw/698b8abfa796491a6985 to your computer and use it in GitHub Desktop.
Save andrewharmellaw/698b8abfa796491a6985 to your computer and use it in GitHub Desktop.
The meaty bits of foldLeft and foldRight
// foldLeft's meaty bit
case Cons(h,t) => foldLeft(t, f(b, h))(f)
// foldRight meaty bit
case Cons(x, xs) => f(x, foldRight(xs, b)(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment