=Functions=
==array:append==
{| width='100%'
| '''Examples'''
|The following query returns the array {{Code|[0, 1, 3]}}:
<syntaxhighlight pre lang="'xquery"'>
array:filter(
array { 0, 1, -2, 3, -4 },
function($i) { $i > 0 }
)
</syntaxhighlightpre>
|}
| '''Examples'''
|The following query returns {{Code|55}} (the sum of the integers 1 to 10):
<syntaxhighlight pre lang="'xquery"'>
array:fold-left(
array { 1 to 10 },
function($a, $b) { $a + $b }
)
</syntaxhighlightpre>
|}
| '''Examples'''
|The following query is equivalent to the expression <code>array:reverse(array { 1 to 5 })</code>:
<syntaxhighlight pre lang="'xquery"'>
array {
array:fold-right(
)
}
</syntaxhighlightpre>
|}
|The following query returns the array {{Code|[2, 3, 4, 5, 6]}}:
<syntaxhighlight pre lang="'xquery"'>
array:for-each(
array { 1 to 5 },
function($i) { $i + 1}
)
</syntaxhighlightpre>
|}
| '''Examples'''
|The following query returns the array {{Code|[5, 7, 9]}}:
<syntaxhighlight pre lang="'xquery"'>
array:for-each-pair(
array { 1 to 3 },
function($a + $b) { $a + $b }
)
</syntaxhighlightpre>
|}
|- valign="top"
| '''Summary'''
| Delivers the contents of an {{Code|$array}} as a sequence of value records.|- valign="top"| '''Note'''| This function is the inverse of [[#array:of-members|array:of-members]].
|- valign="top"
| '''Examples'''
|}
==array:sizeof-members==
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:sizeof-members( $array input as arrayrecord(*)) value as xs:integer</pre>|- valign="top"| '''Summary'''| Returns the number of members in {{Code|$array}}. Note that because an array is an item, the {{Code|fn:count}} function when applied to an array always returns {{Code|1}}.|- valign="top"| '''Examples'''|* <code>array:size(array { 1 to 10 })</code> returns {{Code|10}}.* <code>array:size([1 to 10])</code> returns {{Code|1}}, because the array contains a single sequence with 10 integers.|} ==array:subarray== {| width='100%'| width='120' | '''Signature'''|<pre>array:subarray( $array as array(*), $position as xs:integer, $length as xs:integer := ()) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Constructs a new an array with with {{Code|$length}} members of {{Code|$array}} beginning from the specified contents of an {{Code|$positioninput}}.<br/>The two-argument version sequence of the function returns the same result as the three-argument version when called with {{Code|$length}} equal to the value of {{Code|array:size($array) - $position + 1}}records.
|- valign="top"
| '''ErrorsNote'''|{{Error|FOAY0001|This function is the inverse of [[#Errors}} {{Code|$position}} is less than one, or if {{Code|$position + $length}} is greater than {{Codearray:members|array:size($array) + 1}}.<br/>{{Error|FOAY0002|#Errors}} {{Code|$length}} is less than zeromembers]].
|- valign="top"
| '''Examples'''
|
* <ul> <li><code>array:of-members(())</code> returns {{Code|[]}}.</li> <li><code>array:subarrayof-members(map { 'value': (1 to 5) })</code> returns {{Code|["a"(1, "b"2, 3, 4, "c"5)]}}.</li> <li><code>array:of-members((1 to 5) ! map { 'value': . })</code> returns {{Code|[1, 2, 3, 4, 5]}}.</li> <li><code>array:of-members((1 to 5) ! map { 'value': (., .*.) })</code> returns the array {{Code|["b"(1, "c"1), (2, 4), (3, 9), (4, 16), (5, 25)]}}.</li></ul>
|}
|
* <code>array:append(["a"], 1)</code> returns the array {{Code|[]}}.
|}
==array:size==
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:size(
$array as array(*)
) as xs:integer</pre>
|- valign="top"
| '''Summary'''
| Returns the number of members in {{Code|$array}}. Note that because an array is an item, the {{Code|fn:count}} function when applied to an array always returns {{Code|1}}.
|- valign="top"
| '''Examples'''
|
* <code>array:size(array { 1 to 10 })</code> returns {{Code|10}}.
* <code>array:size([1 to 10])</code> returns {{Code|1}}, because the array contains a single sequence with 10 integers.
|}
==array:subarray==
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:subarray(
$array as array(*),
$position as xs:integer,
$length as xs:integer := ()
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Constructs a new array with with {{Code|$length}} members of {{Code|$array}} beginning from the specified {{Code|$position}}.<br/>The two-argument version of the function returns the same result as the three-argument version when called with {{Code|$length}} equal to the value of {{Code|array:size($array) - $position + 1}}.
|- valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} {{Code|$position}} is less than one, or if {{Code|$position + $length}} is greater than {{Code|array:size($array) + 1}}.<br/>{{Error|FOAY0002|#Errors}} {{Code|$length}} is less than zero.
|- valign="top"
| '''Examples'''
|
* <code>array:subarray(["a", "b", "c"], 2)</code> returns the array {{Code|["b", "c"]}}.
|}
* Added: {{Function||array:build}}
* Added: {{Function||array:foot}}
* Added: {{Function||array:members}}
* Added: {{Function||array:of-members}}
;Version 8.6