map collection's items by applying given action
Parameters
map collection :integer :string :literal :dictionary :object :inline :block :range
params :null :literal :block
condition :block :bytecode
Attributes
with | :literal | use given index |
Returns
Examples
copy
print map 1..5 [x][
2*x
]
; 2 4 6 8 10
copy
arr: 1..5
map 'arr 'x -> 2*x
print arr
; 2 4 6 8 10
copy
map 1..6 [x y][
print ["mapping" x "and" y "->" x+y]
x+y
]
; mapping 1 and 2 -> 3
; mapping 3 and 4 -> 7
; mapping 5 and 6 -> 11
; => [3 7 11]
copy
map.with:'i ["one" "two" "three" "four"] 'x [
(even? i)? -> upper x -> x
]
; => ["ONE" "two" "THREE" "four"]
Related