Changes

Jump to navigation Jump to search
3,458 bytes added ,  21:38, 9 August 2014
no edit summary
==array:size==
 
{| width='100%'
| width='120' | '''Signatures'''
==array:append==
 
{| width='100%'
| width='120' | '''Signatures'''
* <code>array:head(["a", "b"])</code> returns {{Code|"a"}}.
* <code>array:head([["a", "b"], ["c", "d"]])</code> returns the array {{Code|["a", "b"]}}.
|}
 
==array:tail==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:tail|$array as array(*)|array(*)}}
|-
| '''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)}}.
|-
| '''Errors'''
|{{Error|FOAY0001|#Errors}}: The array is empty.
|-
| '''Examples'''
|
* <code>array:insert-before(["a"], 1, "b")</code> returns the array {{Code|["b", "a"]}}.
|}
 
==array:reverse==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:reverse|$array as array(*)|array(*)}}
|-
| '''Summary'''
| Returns a new array with all members of {{Code|$array}} in reverse order.
|-
| '''Examples'''
|
* <code>array:reverse(array { 1 to 3 })</code> returns the array {{Code|[3, 2, 1]}}.
|}
 
==array:join==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:join|$arrays as array(*)*|array(*)}}
|-
| '''Summary'''
| Concatenates the contents of several {{Code|$arrays}} into a single array.
|-
| '''Examples'''
|
* <code>array:join(())</code> returns the array {{Code|[]}}.
* <code>array:join((1 to 3) ! array { . })</code> returns the array {{Code|[1, 2, 3]}}.
|}
 
==array:for-each-member==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:for-each-member|$array as array(*), $function as function(item()*) as item()*|array(*)}}
|-
| '''Summary'''
| Returns a new array, in which each member is computed by applying {{Code|$function}} to the corresponding member of {{Code|$array}}.
|-
| '''Examples'''
|The following query returns the array {{Code|[2, 3, 4, 5, 6]}}:
<pre class="brush:xquery">
array:for-each-member(
array { 1 to 5 },
function($i) { $i + 1}
)
</pre>
|}
 
==array:filter==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:filter|$array as array(*), $function as function(item()*) as xs:boolean|array(*)}}
|-
| '''Summary'''
| Returns a new array with those members of {{$array}} for which {{Code|$function}} returns {{Code|true}}.
|-
| '''Examples'''
|The following query returns the array {{Code|[0, 1, 3]}}:
<pre class="brush:xquery">
array:filter(
array { 0, 1, -2, 3, -4 },
function($i) { $i > 0 }
)
</pre>
|}
 
==array:fold-left==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:fold-left|$array as array(*), $function as function(item()*, item()*) as item()*|item()*}}
|-
| '''Summary'''
| Evaluates the supplied {{Code|$function}} cumulatively on successive members of the supplied {{Code|$array}} from left to right.
</pre>
|}
 
==array:fold-right==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:fold-left|$array as array(*), $function as function(item()*, item()*) as item()*|item()*}}
|-
| '''Summary'''
| Evaluates the supplied {{Code|$function}} cumulatively on successive members of the supplied {{Code|$array}} from right to left.
</pre>
|}
 
==array:for-each-pair==
 
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|array:for-each-pair|$array1 as array(*), $array2 as array(*), $function as function(item()*) as item()*|array(*)}}
|-
| '''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}}.
|-
| '''Examples'''
|The following query returns the array {{Code|[5, 7, 9]}}:
<pre class="brush:xquery">
array:for-each-pair(
array { 1 to 3 },
array { 4 to 6 },
function($a + $b) { $a + $b }
)
</pre>
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu