Changes

Jump to navigation Jump to search
585 bytes added ,  14:16, 20 July 2022
no edit summary
| width='120' | '''Signatures'''
|{{Func|array:size|$input as array(*)|xs:integer}}
|-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'''
|
| width='120' | '''Signatures'''
|{{Func|array:get|$array as array(*), $position as xs:integer|item()*}}
|-valign="top"
| '''Summary'''
| Returns the {{Code|$array}} member at the specified {{Code|$position}}.
|-valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} {{Code|$position}} is not in the range {{Code|1}} to {{Code|array:size($array)}} inclusive.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:append|$array as array(*), $member as item()*|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a copy of {{Code|$array}} with a new {{Code|$member}} attached.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:subarray|$array as array(*), $position as xs:integer|array(*)}}<br/>{{Func|array:subarray|$array as array(*), $position as xs:integer, $length as xs:integer|array(*)}}
|-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'''
|
| width='120' | '''Signatures'''
|{{Func|array:put|$array as array(*), $position as xs:integer, $member as item()*|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a copy of {{Code|$array}} with {{Code|$member}} replaced at the specified {{Code|$position}}. Equivalent to <code>$array => array:remove($position) => array:insert-before($position, $member)</code>.
|-valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} {{Code|$position}} is not in the range {{Code|1}} to {{Code|array:size($array)}} inclusive.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:remove|$array as array(*), $positions as xs:integer*|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a copy of {{Code|$array}} without the member at the specified {{Code|$positions}}.
|-valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} A position is not in the range {{Code|1}} to {{Code|array:size($array)}} inclusive.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:insert-before|$array as array(*), $position as xs:integer, $member as item()*|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a copy of {{Code|$array}} with one new {{Code|$member}} at the specified {{Code|$position}}. Setting {{Code|$position}} to the value {{Code|array:size($array) + 1}} yields the same result as {{Code|array:append($array, $insert)}}.
|-valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} {{Code|$position}} is not in the range {{Code|1}} to {{Code|array:size($array) + 1}} inclusive.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:head|$array as array(*)|item()*}}
|-valign="top"
| '''Summary'''
| Returns the first member of {{Code|$array}}. This function is equivalent to the expression {{Code|$array(1)}}.
|-valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} The array is empty.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:tail|$array as array(*)|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a new array with all members except the first from {{Code|$array}}. This function is equivalent to the expression {{Code|array:remove($array, 1)}}.
|-valign="top"
| '''Errors'''
|{{Error|FOAY0001|#Errors}} The array is empty.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:reverse|$array as array(*)|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a new array with all members of {{Code|$array}} in reverse order.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:join|$arrays as array(*)*|array(*)}}
|-valign="top"
| '''Summary'''
| Concatenates the contents of several {{Code|$arrays}} into a single array.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:flatten|$items as item()*|item()*}}
|-valign="top"
| '''Summary'''
| Recursively flattens all arrays that occur in the supplied {{Code|$items}}.
|-valign="top"
| '''Examples'''
|
| width='120' | '''Signatures'''
|{{Func|array:for-each|$array as array(*), $function as function(item()*) as item()*|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a new array, in which each member is computed by applying {{Code|$function}} to the corresponding member of {{Code|$array}}.
|-valign="top"
| '''Examples'''
|The following query returns the array {{Code|[2, 3, 4, 5, 6]}}:
| width='120' | '''Signatures'''
|{{Func|array:filter|$array as array(*), $function as function(item()*) as xs:boolean|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a new array with those members of {{Code|$array}} for which {{Code|$function}} returns {{Code|true}}.
|-valign="top"
| '''Examples'''
|The following query returns the array {{Code|[0, 1, 3]}}:
| width='120' | '''Signatures'''
|{{Func|array:fold-left|$array as array(*), $zero as item()*, $function as function(item()*, item()*) as item()*|item()*}}
|-valign="top"
| '''Summary'''
| Evaluates the supplied {{Code|$function}} cumulatively on successive members of the supplied {{Code|$array}} from left to right and using {{Code|$zero}} as first argument.
|-valign="top"
| '''Examples'''
|The following query returns {{Code|55}} (the sum of the integers 1 to 10):
| width='120' | '''Signatures'''
|{{Func|array:fold-right|$array as array(*), $zero as item()*, $function as function(item()*, item()*) as item()*|item()*}}
|-valign="top"
| '''Summary'''
| Evaluates the supplied {{Code|$function}} cumulatively on successive members of the supplied {{Code|$array}} from right to left and using {{Code|$zero}} as first argument.
|-valign="top"
| '''Examples'''
|The following query is equivalent to the expression <code>array:reverse(array { 1 to 5 })</code>:
| width='120' | '''Signatures'''
|{{Func|array:for-each-pair|$array1 as array(*), $array2 as array(*), $function as function(item()*) as item()*|array(*)}}
|-valign="top"
| '''Summary'''
| Returns a new array obtained by evaluating the supplied {{Code|$function}} for each pair of members at the same position in {{Code|$array1}} and {{Code|$array2}}.
|-valign="top"
| '''Examples'''
|The following query returns the array {{Code|[5, 7, 9]}}:
| width='120' | '''Signatures'''
|{{Func|array:sort|$array as array(*)|array(*)}}<br/>{{Func|array:sort|$array as array(*), $collation as xs:string?|array(*)}}<br/>{{Func|array:sort|$array as array(*), $collation as xs:string?, $key as function(item()*) as xs:anyAtomicType*|array(*)}}<br/>
|-valign="top"
| '''Summary'''
| Returns a new array with sorted {{Code|$array}} members, using an optional {{Code|$collation}}. If a {{Code|$key}} function is supplied, it will be applied on all array members. The items of the resulting values will be sorted using the semantics of the {{Code|lt}} expression.
|-valign="top"
| '''Examples'''
|
! width="110"|Code
|Description
|-valign="top"
|{{Code|FOAY0001}}
|The specified index extends beyonds the bounds of an array.
|-valign="top"
|{{Code|FOAY0002}}
|The specified length is less than zero.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu