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

9 lines
184 B
Plaintext

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