RosettaCodeData/Task/Apply-a-callback-to-an-array/Toka/apply-a-callback-to-an-array.toka
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

17 lines
358 B
Text

( array count function -- )
{
value| array fn |
[ i array ] is I
[ to fn swap to array 0 swap [ I array.get :stack fn invoke I array.put ] countedLoop ]
} is map-array
( Build an array )
5 cells is-array a
10 0 a array.put
11 1 a array.put
12 2 a array.put
13 3 a array.put
14 4 a array.put
( Add 1 to each item in the array )
a 5 [ 1 + ] map-array