EFUN: map_array

SYNTAX:
mixed *map_array( arr, fun[, ob, extra1, extra2, ...] );
  mixed *arr;
  string fun | closure fun;
  object ob;
  mixed extra#;

DESCRIPTION:
This efun passes each of the elements of array 'arr', and any 'extra#' (if
given) as arguments to a function 'fun' in object 'ob'. The value return
by 'fun' will replace the original value of the element. Note that 'fun'
must be of the same type as 'arr'. If 'ob' is not given, then
this_object() is used by default.

RETURN VALUES:
If 'arr' is not an array, then 0 will be returned.
Otherwise an array is returned of which the elements consist of the
returned values (mixed)ob->fun( arr[element], extra1, extra2, ... ).

SEE ALSO:
filter_array
sort_array

EXAMPLE:
int *num_list, *minimal_squares;

num_list = ({ -2, -1, 0, 1, 2, 3 });
minimal_squares = map_array( minimal_squares, "calc_min_square",
  this_object() , 1 );

int calc_min_square( int i, int min ) {
  if( i < min ) return 0;
  return i * i;
}
// square_list is now ({ 0, 0, 0, 1, 4, 9 })
