RosettaCodeData/Task/Apply-a-callback-to-an-array/Sather/apply-a-callback-to-an-arra...

13 lines
270 B
Plaintext

class MAIN is
do_something(i:INT):INT is
return i * i;
end;
main is
a:ARRAY{INT} := |1, 2, 3, 4, 5|;
-- we use an anonymous closure to apply our do_something "callback"
a.map(bind(do_something(_)));
loop #OUT + a.elt! + "\n"; end;
end;
end;