RosettaCodeData/Task/Call-a-function/Ecstasy/call-a-function-6.ecstasy
2023-07-01 13:44:08 -04:00

11 lines
412 B
Text

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)}
);
}
}