12 lines
412 B
Plaintext
12 lines
412 B
Plaintext
module FirstClassFunctions {
|
|
@Inject Console console;
|
|
void run() {
|
|
function Int(String) stringLen = s -> s.size;
|
|
function Int(Int, Int) sum = (n1, n2) -> n1+n2;
|
|
String[] testData = ["abc", "easy", "as", "123"];
|
|
console.print($|total string length of values in {testData} =\
|
|
| {testData.map(stringLen).reduce(0, sum)}
|
|
);
|
|
}
|
|
}
|