unique_array |
Discworld driver help |
unique_array |
Name
unique_array() - partitions an array of objects into groups
Synopsis
mixed *unique_array( object *obarr, string separator );
mixed *unique_array( object *obarr, string separator, mixed skip );
mixed *unique_array( mixed *arr, function f );
mixed *unique_array( mixed *arr, function f, mixed skip );
Description
Groups objects/values together for which the `separator' function returns the same value. In the first case, `separator' is a string function name to try on each object. In the second case, the function f is called with the element as the argument. If `skip' is passed, elements for which the separator function returns the same as `skip' are omitted from the return value.
Return value
The return value is an array of arrays of the form:
({ ({Same1:1, Same1:2, Same1:3, .... Same1:N }), ({Same2:1, Same2:2, Same2:3, .... Same2:N }), ({Same3:1, Same3:2, Same3:3, .... Same3:N }), .... .... ({SameM:1, SameM:2, SameM:3, .... SameM:N }), })
i.e. an array of arrays, where each of the elements in the sub arrays returned the same value as the other elements in the same sub array.