diff --git a/specifications/xpath-functions-40/src/function-catalog.xml b/specifications/xpath-functions-40/src/function-catalog.xml index 5a579bdaa..a10f156ca 100644 --- a/specifications/xpath-functions-40/src/function-catalog.xml +++ b/specifications/xpath-functions-40/src/function-catalog.xml @@ -31345,7 +31345,7 @@ path with an explicit file: scheme.

- + @@ -31354,11 +31354,16 @@ path with an explicit file: scheme.

focus-independent
-

Produces the complete (ordered) sequence of all partial results from every new value - the accumulator is assigned to during the evaluation of fn:fold-left.

+

Produces the complete (ordered) sequence of all intermediate + results of an evaluation of fn:fold-left.

-

The function is equivalent to the following implementation in XPath (return clause added in comments for completeness):

+

The result of the function is the value of the expression:

+ (1 to count($input)) ! + array{ slice($input, end := .) => fold-left($zero, $action) } + +
-

As a consequence of the function signature and the function calling rules, a type error - occurs if the supplied function $action cannot be applied to two arguments, where - the first argument is either the value of $zero or the result of a previous - application of $action, and the second - is any single item from the sequence $input.

+

See fn:fold-left: errors are raised in the same situations.

- - -

Note that each intermediate result is placed in a separate singleton array. - This is necessary because we cannot represent a sequence of results, some or all of which are - a sequence - that is "sequence of sequences" as just a single sequence. -

-
-
+

A practical implementation might be expected to evaluate the result + incrementally in a single pass of the input; the equivalent expression + given in the rules above is provided purely for formal specification + purposes.

+

Each intermediate result is placed in a separate array. The number of arrays + in the result is the same as the number of items in $input.

+

The fact that the function has the same signature as fn:fold-left + means that this function can conveniently be used to study the behavior of + an call on fn:fold-left with the same arguments, perhaps for + diagnostic purposes.

scan-left(1 to 5, 0, op('+')) - [ 0 ], [ 1 ], [ 3 ], [ 6 ], [ 10 ], [ 15 ] + [ 1 ], [ 3 ], [ 6 ], [ 10 ], [ 15 ] scan-left(1 to 3, 0, op('-')) - [ 0 ], [ -1 ], [ -3 ], [ -6 ] + [ -1 ], [ -3 ], [ -6 ] @@ -31428,7 +31431,7 @@ return scan-left(1 to 3, (), fn($seq, $it) { $seq , $double($it) }) Produce the factorials of all numbers from 0 to 5

scan-left(1 to 5, 1, op('*')) - [ 1 ], [ 1 ], [ 2 ], [ 6 ], [ 24 ], [ 120 ] + [ 1 ], [ 2 ], [ 6 ], [ 24 ], [ 120 ]
@@ -31442,7 +31445,7 @@ return scan-left(1 to 3, (), fn($seq, $it) { $seq , $double($it) }) - + @@ -31451,11 +31454,15 @@ return scan-left(1 to 3, (), fn($seq, $it) { $seq , $double($it) })focus-independent -

Produces the complete (ordered) sequence of all partial results from every new value - the accumulator is assigned to during the evaluation of fn:fold-right.

+

Produces the complete (ordered) sequence of all intermediate + results of an evaluation of fn:fold-right.

-

The function is equivalent to the following implementation in XPath (return clause in comments added for completeness):

+

The result of the function is the value of the expression:

+ + reverse(1 to count($input)) ! + array{ slice($input, start := .) => fold-right($zero, $action) } +
-

As a consequence of the function signature and the function calling rules, a type error - occurs if the supplied function $action cannot be applied to two arguments, where - the first argument is any item in the sequence $input, and the second is either - the value of $zero or the result of a previous application of - $action.

+

See fn:fold-left: errors are raised in the same situations.

- - -

Note that each intermediate result is placed in a separate singleton array. - This is necessary because we cannot represent a sequence of results, some or all of which are - a sequence - that is "sequence of sequences" as just a single sequence. -

-
-
-
+

A practical implementation might be expected to evaluate the result + incrementally in a single right-to-left pass of the input; the equivalent expression + given in the rules above is provided purely for formal specification + purposes.

+

Each intermediate result is placed in a separate array. The number of arrays + in the result is the same as the number of items in $input.

+

The fact that the function has the same signature as fn:fold-right + means that this function can conveniently be used to study the behavior of + an call on fn:fold-right with the same arguments, perhaps for + diagnostic purposes.

+ scan-right(1 to 5, 0, op('+')) - [ 55 ], [ 54 ], [ 52 ], [ 49 ], [ 45 ], -[ 40 ], [ 34 ], [ 27 ], [ 19 ], [ 10 ], [ 0 ] + [ 5 ], [ 9 ], [ 12 ], [ 14 ], [ 15 ] - scan-right(1 to 3, 0, op('-')) - [ 2 ], [ -1 ], [ 3 ], [ 0 ] + scan-right(1 to 5, 0, op('-')) + [ 5 ], [ -1 ], [ 4 ], [ -2 ], [ 3 ]