Changes

Jump to navigation Jump to search
no edit summary
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:fold-left1|$seq as item()+, $f as function(item()*, item()) as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Works the same as [[Higher-Order Functions#fn:fold-left|fn:fold-left]], but does not need a seed, because the sequence must be non-empty.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:until|$pred as function(item()*) as xs:boolean, $f as function(item()*) as item()*, $start as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Applies the predicate function {{Code|$pred}} to {{Code|$start}}. If the result is {{Code|false}}, {{Code|$f}} is invoked with the start value – or, subsequently, with the result of this function – until the predicate function returns {{Code|true()}}.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:scan-left|$seq as item()*, $start as item()*, $f as function(item()*, item()) as item()*|item()*}}
|-valign="top"
| '''Summary'''
|This function is similar to [[Higher-Order Functions#fn:fold-left|fn:fold-left]], but it returns a list of successive reduced values from the left. It is equivalent to:
};
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:take-while|$seq as item()*, $pred as function(item()) as xs:boolean|item()*}}
|-valign="top"
| '''Summary'''
|The function returns items of <code>$seq</code> as long as the predicate <code>$pred</code> is satisfied. It is equivalent to:
};
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:drop-while|$seq as item()*, $pred as function(item()) as xs:boolean|item()*}}
|-valign="top"
| '''Summary'''
|The function skips all items of <code>$seq</code> until the predicate <code>$pred</code> is not satisfied anymore. It is equivalent to:
};
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|Returns the name of the first file that does not exist on disk:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:top-k-by|$seq as item()*, $sort-key as function(item()) as item(), $k as xs:integer|item()*}}
|-valign="top"
| '''Summary'''
|Returns the {{Code|$k}} items in {{Code|$seq}} that are greatest when sorted by the result of {{Code|$f}} applied to the item. The function is a much more efficient implementation of the following scheme:
)[position() <= $k]
</syntaxhighlight>
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:top-k-with|$seq as item()*, $lt as function(item(), item()) as xs:boolean, $k as xs:integer|item()*}}
|-valign="top"
| '''Summary'''
|Returns the {{Code|$k}} items in {{Code|$seq}} that are greatest when sorted in the order of the ''less-than'' predicate {{Code|$lt}}. The function is a general version of {{Code|hof:top-k-by($seq, $sort-key, $k)}}.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:id|$expr as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Returns its argument unchanged. This function isn’t useful on its own, but can be used as argument to other higher-order functions.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|hof:const|$expr as item()*, $ignored as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Returns its first argument unchanged and ignores the second. This function isn’t useful on its own, but can be used as argument to other higher-order functions, e.g. when a function combining two values is expected and one only wants to retain the left one.
|-valign="top"
| '''Examples'''
|
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu