Created
March 15, 2013 22:21
-
-
Save CaglarGonul/5173579 to your computer and use it in GitHub Desktop.
mapreduce intuition
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 mapReduce(f:Int=>Int,combine: (Int,Int)=>Int, zero:Int)(a:Int,b:Int):Int ={ | |
if(a>b) zero | |
else ??? | |
} | |
def sumGN(f:Int=>Int)(a:Int,b:Int) = mapReduce(f, (x,y)=>(x+y), 0)(a, b) | |
def productGN(f:Int=>Int)(a:Int,b:Int) = mapReduce(f, (x,y)=>(x*y), 1)(a, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment