Method Array.uniq()


Method uniq

array uniq(array a, function(mixed, mixed:bool)|void cmp)

Description

Remove elements that are duplicates.

Parameter a

Array that may contain duplicate elements.

Parameter cmp

Function to use for comparing elements. If not specified, the elements will be compared with `==() and hashed (cf lfun::__hash()).

Returns

This function returns an copy of the array a with all duplicate values removed. The order of the values is kept in the result; it's always the first of several equal elements that is kept.

Note

The cmp argument is only available in Pike 9.1 and later.

Note

The cmp function MUST return non-zero for all element pairs that `==() considers equal.