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
var TextEncoder = require("text-encoding").TextEncoder; | |
var TextDecoder = require("text-encoding").TextDecoder; | |
var jsSource = ""; | |
process.stdin.resume(); | |
process.stdin.on("data", function(buf) { | |
jsSource += buf.toString(); | |
}); | |
process.stdin.on("end", function() { |
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 mapReduce = { collection, mapper, reducer -> | |
collection.groupBy(mapper) | |
.collectEntries { k, v -> | |
[k, reducer(v)] | |
} | |
} | |
mapReduce([1, 6, 3, 7, 3, 9, 1, 2, 10, 9, 5, 8, 4], | |
{ it % 2 ? "odd" : "even" }, | |
{ it.size }) |
NewerOlder