17 lines
369 B
Text
17 lines
369 B
Text
use Collection;
|
|
|
|
class Reducer {
|
|
function : Main(args : String[]) ~ Nil {
|
|
values := IntVector->New([1, 2, 3, 4, 5]);
|
|
values->Reduce(Add(Int, Int) ~ Int)->PrintLine();
|
|
values->Reduce(Mul(Int, Int) ~ Int)->PrintLine();
|
|
}
|
|
|
|
function : Add(a : Int, b : Int) ~ Int {
|
|
return a + b;
|
|
}
|
|
|
|
function : Mul(a : Int, b : Int) ~ Int {
|
|
return a * b;
|
|
}
|
|
}
|