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

8 lines
184 B
Text

int cube(int n)
{
return n*n*n;
}
array(int) a = ({ 1,2,3,4,5 });
array(int) b = cube(a[*]); // automap operator
array(int) c = map(a, cube); // conventional map function