diff --git a/specifications/xpath-functions-40/src/function-catalog.xml b/specifications/xpath-functions-40/src/function-catalog.xml
index dce940113..a6e5d2216 100644
--- a/specifications/xpath-functions-40/src/function-catalog.xml
+++ b/specifications/xpath-functions-40/src/function-catalog.xml
@@ -33,6 +33,22 @@
+ This record type represents an item and its integer position within a sequence. The one-based position of the item within a containing sequence. The item itself. This record type represents the components of a URI.
The function calls $action($item, $pos)
for each item in $input
,
- where $item
is the item in question and $pos
is its 1-based
- ordinal position in $input
. The final result is the sequence concatenation
+
The function calls $action($item)
for each item in $input
,
+ where $item
is the item in question. The final result is the sequence concatenation
of the result of these calls, preserving order
(provided that ordering mode is ordered
).
If evaluation of the action requires access to the position of the item
+ in the sequence, it is possible to call the function with numbered-items($input)
+ as the first argument.
The function returns a sequence containing those items from $input
- for which $predicate($item, $pos)
returns true
, where $item
- is the item in question, and $pos
is its 1-based ordinal position within $input
.
$predicate($item)
returns true
, where $item
+ is the item in question.
fn:lang#1
will give different results in
the two cases.
+ If evaluation of the predicate requires access to the position of the item
+ in the sequence, it is possible to call the function with numbered-items($input)
+ as the first argument.
If $input
is empty, the function returns $zero
.
If $input
contains a single item $item1
, the function calls
- $action($zero, $item1, 1)
.
$action($zero, $item1)
.
If $input
contains a second item $item2
, the function then calls
- $action($zero1, $item2, 2)
, where $zero1
is the result after
+ $action($zero1, $item2)
, where $zero1
is the result after
processing the first item.
This continues in the same way until the end of the $input
sequence; the final result is
the result of the last call on $action
.
As a consequence of the function signature and the function calling rules, a type error @@ -21073,9 +21082,7 @@ declare function fold-left(
This operation is often referred to in the functional programming literature as
“folding” or “reducing” a sequence. It typically takes a function that operates on a pair of
values, and applies it repeatedly, with an accumulated result as the first argument, and
- the next item in the sequence as the second argument. Optionally the $action
- function may take a third argument, which is set to the 1-based position of the current
- item in the input sequence. The accumulated result is
+ the next item in the sequence as the second argument. The accumulated result is
initially set to the value of the $zero
argument, which is conventionally a
value (such as zero in the case of addition, one in the case of multiplication, or a
zero-length string in the case of string concatenation) that causes the function to
@@ -21186,9 +21193,9 @@ return fold-left($input, (),
The $predicate
callback function may return an empty sequence (meaning false
).
If $input
is empty, the function returns $zero
.
Let $itemN
be the last item in $input
, and let $N
- be its 1-based ordinal position in $input
(that is, the size of $input
).
- The function starts by calling $action($itemN, $zero, $N)
.
If there is a previous item, $itemN-1
, at position $N - 1
,
- the function then calls $action($itemN-1, $zeroN, $N - 1)
, where $zeroN
is the result
+
Let $itemN
be the last item in $input
.
+ The function starts by calling $action($itemN, $zero)
.
If there is a previous item $prev
,
+ the function then calls $action($prev, $zeroN)
, where $zeroN
is the result
of the previous call.
This continues in the same way until the start of the $input
sequence is reached; the final result is
the result of the last call on $action
.
As a consequence of the function signature and the function calling rules, a type error @@ -21272,9 +21264,7 @@ declare function fold-right (
In cases where the function performs an associative operation on its two arguments (such
as addition or multiplication),
The value of the third argument of $action
corresponds to the position
- of the item in the input sequence. Thus, in contrast to
New in 4.0
Returns a sequence of numbered-item
records
+ corresponding to the items in a sequence.
The function returns a sequence of maps, one for each item in the input,
+ retaining order, in which each map has an entry with key "item"
+ containing the item, and an entry with key "position" containing its one-based position.
New in 4.0
If the second argument is omitted or an empty sequence, the predicate defaults
to fn:boolean#1
, which takes the effective boolean value of each item.
It is possible for the supplied $predicate
to be a function whose arity is less than two.
- The coercion rules mean that the additional parameters are effectively ignored. Frequently a predicate
- function will only consider the item itself, and disregard its position in the sequence.
If evaluation of the predicate requires access to the position of the item
+ in the sequence, it is possible to call the function with numbered-items($input)
+ as the first argument.
The predicate is required to return either true
, false
, or an empty
sequence (which is treated as false
). A predicate such as fn{self::h1}
results in a type error because it returns a node, not a boolean.
Returns true
if at least one item in the input sequence matches a supplied predicate.
The function returns true if (and only if) there is an item $item
at position $pos
+
The function returns true if (and only if) there is an item $item
in the input sequence such that $predicate($item, $pos)
returns true.
If the second argument is omitted or an empty sequence, the predicate defaults
to fn:boolean#1
, which takes the effective boolean value of each item.
It is possible for the supplied $predicate
to be a function whose arity is less than two.
- The coercion rules mean that the additional parameters are effectively ignored. Frequently a predicate
- function will only consider the item itself, and disregard its position in the sequence.
If evaluation of the predicate requires access to the position of the item
+ in the sequence, it is possible to call the function with numbered-items($input)
+ as the first argument.
The predicate is required to return either true
, false
, or an empty
sequence (which is treated as false
). A predicate such as fn{self::h1}
results in a type error because it returns a node, not a boolean.
file:
scheme.
file:
scheme.