<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.subsequence.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.subsequence</api:function-name><api:suggest>fn.subsequence</api:suggest><api:suggest>fn</api:suggest><api:suggest>subsequence</api:suggest><api:function-link mode="xquery" fullname="fn:subsequence">/apidoc/8.0/fn:subsequence.xml</api:function-link><api:function mode="javascript" name="subsequence" type="builtin" lib="fn" category="SequenceBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.subsequence"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the contiguous sequence of items in the value of $sourceSeq beginning
at the position indicated by the value of $startingLoc and continuing for the
number of items indicated by the value of $length.
</p><p xmlns="http://www.w3.org/1999/xhtml">
In the two-argument case, returns:
</p><p xmlns="http://www.w3.org/1999/xhtml">
$sourceSeq[fn:round($startingLoc) le $p]
</p><p xmlns="http://www.w3.org/1999/xhtml">
In the three-argument case, returns:
</p><p xmlns="http://www.w3.org/1999/xhtml">
$sourceSeq[fn:round($startingLoc) le $p
     and $p lt fn:round($startingLoc) + fn:round($length)]
</p><p xmlns="http://www.w3.org/1999/xhtml">
Notes:
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $sourceSeq is the empty sequence, the empty sequence is returned.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $startingLoc is zero or negative, the subsequence includes items from the
beginning of the $sourceSeq.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $length is not specified, the subsequence includes items to the end of
$sourceSeq.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $length is greater than the number of items in the value of $sourceSeq
following $startingLoc, the subsequence includes items to the end of
$sourceSeq.
</p><p xmlns="http://www.w3.org/1999/xhtml">
The first item of a sequence is located at position 1, not position 0.
</p><p xmlns="http://www.w3.org/1999/xhtml">
For detailed type semantics, see Section 7.2.13 The fn:subsequence functionFS.
</p><p xmlns="http://www.w3.org/1999/xhtml">
The reason the function accepts arguments of type xs:double is that many
computations on untyped data return an xs:double result; and the reason for the
rounding rules is to compensate for any imprecision in these floating-point
computations.
</p>
</api:summary><api:params><api:param name="sourceSeq" type="ValueIterator" class="javascript"><api:param-description>
  A sequence of items (as a ValueIterator) from which a subsequence will be 
  selected.  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.subsequence</code> will treat the array as
  a single-item sequence. 
  If you mean to get the subsequence 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>sourceSeq</api:param-name><api:param-type>ValueIterator</api:param-type></api:param><api:param name="startingLoc" type="xs:double"><api:param-description>
  The starting position of the start of the subsequence.
  </api:param-description><api:param-name>startingLoc</api:param-name><api:param-type>Number</api:param-type></api:param><api:param name="length" type="xs:double" optional="true"><api:param-description>
  The length of the subsequence.
  </api:param-description><api:param-name>length</api:param-name><api:param-type>Number</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">
var seq = xdmp.arrayValues(["item1", "item", "item3", "item4" , "..."]);
fn.subsequence(seq, 4)
=&gt; (item4, ...)

var seq = xdmp.arrayValues(["item1", "item", "item3", "item4" , "..."]);
fn.subsequence(seq, 3, 2)
=&gt; (item3, item4)
</pre>
</api:example></api:function></api:function-page>