Apply a callback to an array: Difference between revisions

Line 1,655:
 
=={{header|Guish}}==
{{works with|guish|2.14.70}}
<syntaxhighlight lang="guish">
# applies add2 (adds 2) to each element
map = {
r =
args = [tail(@*)]
for x @args {
r = [@r, call(@1, @x)]
}
return @r
}
 
add2 = {
return add(@1, 2)
}
dumpl map(add2,= {1, 2, 3, 4, 5, 6, 7)}
dump each(add2, flat(@l))
</syntaxhighlight>
 
39

edits