Created
March 15, 2013 23:05
-
-
Save CaglarGonul/5173861 to your computer and use it in GitHub Desktop.
map reduce elegant
This file contains hidden or 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 mapReducev1(f: Int => Int, combine: (Int, Int) => Int, zero: Int)(a: Int, b: Int): Int = { | |
if (a > b) zero | |
else (a to b).map(f).reduce(combine) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment