Anonymous user
Apply a callback to an array: Difference between revisions
I added Salmon code.
(add link to Delphi for pascal) |
(I added Salmon code.) |
||
Line 1,506:
To create a new array of each value squared
<lang ruby>[1,2,3,4,5].map{ |i| i**2 }</lang>
=={{header|Salmon}}==
<lang Salmon>function apply(list, ageless to_apply)
(comprehend(x; list) (to_apply(x)));
function square(x) (x*x);
iterate(x; apply([0...9], square))
x!;</lang>
With short identifiers:
<lang Salmon>include "short.salm";
fun apply(list, ageless to_apply)
(comp(x; list) (to_apply(x)));
fun square(x) (x*x);
iter(x; apply([0...9], square))
x!;</lang>
=={{header|Sather}}==
|