Changes

Jump to navigation Jump to search
No change in size ,  15:18, 16 November 2023
Reorder
</li>
</ul>
|}
 
==array:filter==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:filter(
$array as array(*),
$predicate as function(item()*) as xs:boolean
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Returns a new array with those members of {{Code|$array}} for which {{Code|$predicate}} returns {{Code|true}}.
|- valign="top"
| '''Examples'''
|The following query returns the array {{Code|[0, 1, 3]}}:
<syntaxhighlight lang="xquery">
array:filter(
array { 0, 1, -2, 3, -4 },
function($i) { $i > 0 }
)
</syntaxhighlight>
|}
 
==array:flatten==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:flatten(
$items as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
| Recursively flattens all arrays that occur in the supplied {{Code|$items}}.
|- valign="top"
| '''Examples'''
|
* <code>array:flatten(["a","b"])</code> returns the sequence {{Code|"a", "b"}}.
* <code>array:flatten([1,[2,3],4]])</code> returns the sequence {{Code|1, 2, 3, 4}}.
|}
 
==array:fold-left==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:fold-left(
$array as array(*),
$zero as item()*,
$action as function(item()*, item()*) as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
| Evaluates the supplied {{Code|$action}} cumulatively on successive members of the supplied {{Code|$array}} from left to right, and uses {{Code|$zero}} as first argument.
|- valign="top"
| '''Examples'''
|The following query returns {{Code|55}} (the sum of the integers 1 to 10):
<syntaxhighlight lang="xquery">
array:fold-left(
array { 1 to 10 },
0,
function($a, $b) { $a + $b }
)
</syntaxhighlight>
|}
 
==array:fold-right==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:fold-right(
$array as array(*),
$zero as item()*,
$action as function(item()*, item()*) as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
| Evaluates the supplied {{Code|$action}} cumulatively on successive members of the supplied {{Code|$array}} from right to left, and uses {{Code|$zero}} as first argument.
|- valign="top"
| '''Examples'''
|The following query is equivalent to the expression <code>array:reverse(array { 1 to 5 })</code>:
<syntaxhighlight lang="xquery">
array {
array:fold-right(
array { 1 to 5 },
(),
function($a, $b) { $b, $a }
)
}
</syntaxhighlight>
|}
 
==array:for-each==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:for-each(
$array as array(*),
$action as function(item()*) as item()*
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Returns a new array, in which each member is computed by applying {{Code|$action}} to the corresponding member of {{Code|$array}}.
|- valign="top"
| '''Examples'''
|The following query returns the array {{Code|[2, 3, 4, 5, 6]}}:
 
<syntaxhighlight lang="xquery">
array:for-each(
array { 1 to 5 },
function($i) { $i + 1}
)
</syntaxhighlight>
|}
 
==array:for-each-pair==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:for-each-pair(
$array1 as array(*),
$array2 as array(*),
$action as function(item()*) as item()*
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Returns a new array obtained by evaluating the supplied {{Code|$action}} 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]}}:
<syntaxhighlight lang="xquery">
array:for-each-pair(
array { 1 to 3 },
array { 4 to 6 },
function($a + $b) { $a + $b }
)
</syntaxhighlight>
|}
* <code>array:join(())</code> returns the array {{Code|[]}}.
* <code>array:join((1 to 3) ! array { . })</code> returns the array {{Code|[1, 2, 3]}}.
|}
 
==array:flatten==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:flatten(
$items as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
| Recursively flattens all arrays that occur in the supplied {{Code|$items}}.
|- valign="top"
| '''Examples'''
|
* <code>array:flatten(["a","b"])</code> returns the sequence {{Code|"a", "b"}}.
* <code>array:flatten([1,[2,3],4]])</code> returns the sequence {{Code|1, 2, 3, 4}}.
|}
 
==array:for-each==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:for-each(
$array as array(*),
$action as function(item()*) as item()*
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Returns a new array, in which each member is computed by applying {{Code|$action}} to the corresponding member of {{Code|$array}}.
|- valign="top"
| '''Examples'''
|The following query returns the array {{Code|[2, 3, 4, 5, 6]}}:
 
<syntaxhighlight lang="xquery">
array:for-each(
array { 1 to 5 },
function($i) { $i + 1}
)
</syntaxhighlight>
|}
 
==array:filter==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:filter(
$array as array(*),
$predicate as function(item()*) as xs:boolean
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Returns a new array with those members of {{Code|$array}} for which {{Code|$predicate}} returns {{Code|true}}.
|- valign="top"
| '''Examples'''
|The following query returns the array {{Code|[0, 1, 3]}}:
<syntaxhighlight lang="xquery">
array:filter(
array { 0, 1, -2, 3, -4 },
function($i) { $i > 0 }
)
</syntaxhighlight>
|}
 
==array:fold-left==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:fold-left(
$array as array(*),
$zero as item()*,
$action as function(item()*, item()*) as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
| Evaluates the supplied {{Code|$action}} cumulatively on successive members of the supplied {{Code|$array}} from left to right, and uses {{Code|$zero}} as first argument.
|- valign="top"
| '''Examples'''
|The following query returns {{Code|55}} (the sum of the integers 1 to 10):
<syntaxhighlight lang="xquery">
array:fold-left(
array { 1 to 10 },
0,
function($a, $b) { $a + $b }
)
</syntaxhighlight>
|}
 
==array:fold-right==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:fold-right(
$array as array(*),
$zero as item()*,
$action as function(item()*, item()*) as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
| Evaluates the supplied {{Code|$action}} cumulatively on successive members of the supplied {{Code|$array}} from right to left, and uses {{Code|$zero}} as first argument.
|- valign="top"
| '''Examples'''
|The following query is equivalent to the expression <code>array:reverse(array { 1 to 5 })</code>:
<syntaxhighlight lang="xquery">
array {
array:fold-right(
array { 1 to 5 },
(),
function($a, $b) { $b, $a }
)
}
</syntaxhighlight>
|}
 
==array:for-each-pair==
 
{| width='100%'
| width='120' | '''Signature'''
|<pre>array:for-each-pair(
$array1 as array(*),
$array2 as array(*),
$action as function(item()*) as item()*
) as array(*)</pre>
|- valign="top"
| '''Summary'''
| Returns a new array obtained by evaluating the supplied {{Code|$action}} 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]}}:
<syntaxhighlight lang="xquery">
array:for-each-pair(
array { 1 to 3 },
array { 4 to 6 },
function($a + $b) { $a + $b }
)
</syntaxhighlight>
|}
administrator, Bureaucrats, editor, reviewer, Administrators
57

edits

Navigation menu