Own-Programming-Language-Tu.../examples/functions/tomap.own
2024-04-28 22:39:30 +03:00

8 lines
344 B
Scala

use std, functional
data = ["apple", "banana", "cherry", "apricot", "coconut"]
println tomap(data, def(str) = str.substring(0, 1))
println tomap(data, def(str) = str.substring(0, 1), ::toUpperCase)
println tomap(data, def(str) = str.substring(0, 1), ::toUpperCase, ::joinValues)
def joinValues(oldValue, newValue) = oldValue + ", " + newValue