<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.distinctValues.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.distinctValues</api:function-name><api:suggest>fn.distinctvalues</api:suggest><api:suggest>fn</api:suggest><api:suggest>distinctvalues</api:suggest><api:function-link mode="xquery" fullname="fn:distinct-values">/apidoc/8.0/fn:distinct-values.xml</api:function-link><api:function mode="javascript" name="distinctValues" type="builtin" lib="fn" category="SequenceBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.distinctValues"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
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. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
The static type of the result is a sequence of prime types as defined in
<a href="http://www.w3.org/TR/xquery-semantics/#sec_fn_distinct_node_vals">Section 7.2.7 The fn:distinct-values function[FS]</a>.
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is the empty sequence, the empty sequence is returned.
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
Which value of a set of values that compare equal is returned is
implementation dependent.
</p>
</api:summary><api:params><api:param name="arg" type="ValueIterator" class="javascript"><api:param-description>
  A sequence of items (as a ValueIterator).  If you pass in a single value, 
  it is treated as a ValueIterator with that single item; therefore, if you 
  pass in an array, <code xmlns="http://www.w3.org/1999/xhtml">fn.distinctValues</code> will return the array. 
  If you mean to get the distinct values of each item in the array, then
  you can call <a href="./xdmp.arrayValues" xmlns="http://www.w3.org/1999/xhtml"><code>xdmp.arrayValues</code></a> 
  on the array. 
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>ValueIterator</api:param-type></api:param><api:param name="collation" type="xs:string" optional="true"><api:param-description>
  The optional name of a valid collation URI.  For information on the
  collation URI syntax, see the <em xmlns="http://www.w3.org/1999/xhtml">Search Developer's Guide</em>.
  </api:param-description><api:param-name>collation</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.distinctValues(xdmp.arrayValues([1, 2.0, 3, 2]));
=&gt; (1, 3, 2.0)

var x = xdmp.arrayValues(["cherry", "bar", "bar"]);
fn.distinctValues(x);
                                   
=&gt; ("cherry", "bar")
</pre></api:example></api:function></api:function-page>