Loading TOC...

fn.distinctValues

fn.distinctValues(
   $arg as Sequence,
   [$collation as String]
) as Sequence

Summary

Returns the sequence that results from removing from $arg all but one of a set of values that are eq to one other. Values that cannot be compared, i.e. the eq operator is not defined for their types, are considered to be distinct. Values of type xs:untypedAtomic are compared as if they were of type xs:string. The order in which the sequence of values is returned is implementation dependent.

The static type of the result is a sequence of prime types as defined in Section 7.2.7 The fn:distinct-values function[FS].

The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. The collation is used when string comparison is required.

If $arg is the empty sequence, the empty sequence is returned.

For xs:float and xs:double values, positive zero is equal to negative zero and, although NaN does not equal itself, if $arg contains multiple NaN values a single NaN is returned.

If xs:dateTime, xs:date or xs:time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for the purpose of comparison. Note that xs:dateTime, xs:date or xs:time values can compare equal even if their timezones are different.

Which value of a set of values that compare equal is returned is implementation dependent.

Parameters
$arg A Sequence of items. If you pass in a single value, it is treated as a Sequence with that single item; therefore, if you pass in an array, fn.distinctValues will return the array. If you mean to get the distinct values of each item in the array, then you can call xdmp.arrayValues on the array.
$collation The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide.

Example

fn.distinctValues(xdmp.arrayValues([1, 2.0, 3, 2]));
=> (1, 3, 2.0)

var x = xdmp.arrayValues(["cherry", "bar", "bar"]);
fn.distinctValues(x);
                                   
=> ("cherry", "bar")

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy