Created
September 7, 2015 22:24
-
-
Save invkrh/a48839774a1a0c03978d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foldRightViaFoldLeft_1[A, B](l: List[A], z: B)(f: (A, B) => B): B = | |
foldLeft(l, (x: B) => x)((g, a) => (b: B) => g(f(a, b)))(z) | |
def foldLeftViaFoldRight[A, B](l: List[A], z: B)(f: (B, A) => B): B = | |
foldRight(l, (b: B) => b)((a, g) => b => g(f(b, a)))(z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment