Changes

Jump to navigation Jump to search
639 bytes removed ,  16:46, 11 November 2023
no edit summary
* {{Code|hof:top-k-with(1 to 1000, function($a, $b) { $a lt $b }, 5)}} returns {{Code|1000 999 998 997 996}}
* {{Code|hof:top-k-with(-5 to 5, function($a, $b) { abs($a) gt abs($b) }, 5)}} returns {{Code|0 1 -1 2 -2}}
|}
 
=IDs=
 
==hof:id==
 
{| width='100%'
|- valign="top"
| width='120' | '''Signature'''
|<pre>hof:id(
$input as item()*
) as item()*</pre>
|- valign="top"
| '''Summary'''
|Returns its argument unchanged. This function isn’t useful on its own, but can be used as an argument to other higher-order functions.
|- valign="top"
| '''Examples'''
|
* {{Code|hof:id(1 to 5)}} returns {{Code|1 2 3 4 5}}
* With higher-order functions:
<syntaxhighlight lang="xquery">
let $sort := sort(?, (), hof:id#1)
let $reverse-sort := sort(?, (), function($x) { -$x })
return (
$sort((1, 5, 3, 2, 4)),
'|',
$reverse-sort((1, 5, 3, 2, 4))
)
</syntaxhighlight>
returns: <code>1 2 3 4 5 | 5 4 3 2 1</code>
|}
;Version 11.0
* Removed: {{Code|hof:until}} (replaced with {{Code|fn:iterate-while}}, {{Code|hof:if}} (replaced with {{Code|fn:identity}}
;Version 9.5
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu