/doc/efun/map_array


SYNOPSIS

mixed *map_array(mixed *arr, string fun, object ob, mixed extra)
mixed *map_array(mixed *arr, closure cl, mixed extra)

DESCRIPTION

Returns an array holding the items of arr mapped through ob->fun(element, extra) resp. the closure cl. The function fun in ob is called for each element in arr with that element as parameter. A second parameter extra is sent in each call if given. ob can be an object or a string. Principal function

foreach (index) arr[index] = ob->fun(arr[index],extra);

The value returned by ob->fun(array[index],extra) replaces the existing element in the array. If arr is not an array, then 0 will be returned.

The extra argument is optional. ob can also be a file_name. If ob is omitted, this_object() is default.

EXAMPLE

	string ask_for_uid(object obj) {
	   return getuid(obj);
	}
	void func() {
	   string *names;
	   names = map_array(users(), "ask_for_uid", this_object());
	   /* equivalent but a bit smaller and faster is the following */
	   names = map_array(users(), #'getuid );
	   ...
	}
This will create an array holding all uids of the current users.

SEE ALSO

filter_array
filter_objects
assoc
intersect_alist
insert_alist
map_objects
member_array
order_alist
sort_array
unique_array

| Home | Applied | Concepts | Efuns | Help | Intro | Lib | LPC | Prop | Obj | Sefuns | Std | W |

Nightfall@quest.tat.physik.uni-tuebingen.de
Automatically generated on Don, 11. Apr 1996