This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26476 - Signature of array:fold-right and array:fold-left
Summary: Signature of array:fold-right and array:fold-left
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Working drafts
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-30 21:37 UTC by arve.gengelbach
Modified: 2014-11-17 09:46 UTC (History)
0 users

See Also:


Attachments

Description arve.gengelbach 2014-07-30 21:37:46 UTC
Hej,
just looking at the working draft on the array section. I know this is work in progress. However I’d like to know how the signature of array:fold-right (and left) is motivated.
Present signature is …

Section 17.3.13 array:fold-right
array:fold-right(
	$array	 as array(*),
	$zero	 as item()*,
	$function	as function(item()*) as item()*
) as array(*)


I’d expect an array:fold-right to be equivalent to the query:


declare function array:fold-right(
        $array	 as array(*),
	$zero	 as item()*,
        $function	 as function(item()*, item()*) as item()*
) as item()* {
  if (array:size($seq) = 0)
  then $zero
  else $function(array:head($array), fn:fold-right(array:tail($array), $zero, $function))
};

Hence the signature to be different to the one presently mentioned in the draft. This signature then would be in analogy to fn:fold-right.
Comment 1 Michael Kay 2014-07-30 22:27:13 UTC
You're right - thanks for pointing out this error.
Comment 2 Michael Kay 2014-09-07 13:58:53 UTC
Fixed in the next draft.
Comment 3 Michael Kay 2014-11-17 09:46:48 UTC
For the record, this was not fully/correctly fixed in the Oct 2014 WD, and resurfaces as bug #27231