Created
June 17, 2011 11:04
-
-
Save mike-neck/1031220 to your computer and use it in GitHub Desktop.
GPars Sample Map-Reduce
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
import static groovyx.gpars.GParsPool.*; | |
withPool { | |
assert 30 == | |
[1,2,3,4,5,6,7,8,9,10].parallel | |
.filter { | |
println "filter -> $it" | |
it <= 5 | |
} | |
.map { | |
println "map -> $it" | |
it * 2 | |
} | |
.reduce {a, b -> | |
println "reduce $a $b" | |
a + b | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment