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

9 lines
184 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
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