map
function:
Map a list into a new list using a function. If the first argument is a list, activate the second argument on each item and collect into a new list.
Examples:
- running:
(map [1, 2, 3, 4], (+ . 4))
will give:[5, 6, 7, 8]
- running:
(map [1, 2, 3, 4], (.len))
will give:[]
- running:
(map [1, 2, 3, "4"], (* . 2))
will give:[2, 4, 6]
Because"4"
is a string and not a number, so it can't be multiple.
- running:
(map ., (+ 2 .))
for input:[1, 2, null, "a", 4]
will give:[3, 4, 6]
- running:
(map .list, (+ ^.add .))
for input:{"list": [1, 2, 3, 4], "add": 12}
will give:[13, 14, 15, 16]
- running:
(map ., (map . (+ (len ^^.) .)))
for input:[[1, 2, 3, 4], [1, 2, 3], [6, 7]]
will give:[[4, 5, 6, 7], [4, 5, 6], [9, 10]]
Because it will add the length of the input list (i.e. 3) to each item in each list in that list.
- running:
(map {}, true)
will return nothing