View Problem

Perform an operation on every item of a list

Perform an operation on every item of a list, e.g.
for the list ["ox", "cat", "deer", "whale"] calculate
the list of sizes of the strings, e.g. [2, 3, 4, 5]
DiskEdit
fsharp 1.9.9.9
let lengths = List.map String.length ["ox"; "cat"; "deer"; "whale"]
DiskEdit
erlang
lists:map(fun (X) ->length(X) end, List).
DiskEdit
clojure
(map count ["ox" "cat" "deer" "whale"])
DiskEdit
groovy
animals = ["ox", "cat", "deer", "whale"]
assert animals*.size() == [2, 3, 4, 5]

Submit a new solution for fsharp, erlang, clojure, or groovy
There are 13 other solutions in additional languages (cpp, csharp, fantom, haskell ...)