/doc/efun/filter_array


SYNOPSIS

mixed *filter_array(mixed *arr, string fun, object ob, mixed extra, ...)
mixed *filter_array(mixed *arr, closure cl, mixed extra, ...)
mixed *filter_array(mixed *arr, mapping map, mixed extra, ...)

DESCRIPTION

Returns an array holding the items of arr filtered through ob->fun(element, extra, ...), the closure cl, or the mapping map. The function 'fun' in 'ob' resp. the closure 'cl' is called for each element in arr with that element as parameter. The extra and following parameters are in each call if given. The mapping 'map' is likewise indexed by each element. If ob->fun(arr[index], extra) returns != 0 resp. map[arr[index]] exists, the element is included in the returned array.

If arr is not an array, an error occurs.

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

Since 3.2.1@36, the second arg can also be a mapping. Then only the elements of the array which belong to the map (as keys) will be returned (i.e. map[arr[index]] != 0).

EXAMPLE

	int check_if_idle(object user) { return query_idle(user); }
	...
	object *idle_users;
	idle_users = filter_array(users(), "check_if_idle");
	/* equivalent but smaller and faster */
	idle_users = filter_array(users(), #'query_idle );
Now idle_users contains all users that have been idle for more than 1 second.

SEE ALSO

filter_objects
map_array
map_objects

| 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