<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29626</bug_id>
          
          <creation_ts>2016-05-15 18:02:10 +0000</creation_ts>
          <short_desc>fn:fold-left in appendix - calls not correct</short_desc>
          <delta_ts>2016-07-21 14:14:13 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>28885</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Hans-Juergen Rennau">hrennau</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>126435</commentid>
    <comment_count>0</comment_count>
    <who name="Hans-Juergen Rennau">hrennau</who>
    <bug_when>2016-05-15 18:02:10 +0000</bug_when>
    <thetext>In the appendix, examples use incorrect invocations of fn:fold-left - the order of arguments is ($f, $zero, $seq) - whereas it should be ($seq, $zero, $f). 

This concerns the following examples (XSLT and XQuery):
* eg:distinct-nodes-stable
* eg:higheest
* eg:lowest


Example:

declare function eg:highest(
                     $f as function(item()) as xs:anyAtomicType, 
                     $seq as item()*)
                  as item()* {
     fn:fold-left(
       function($highestSoFar as item()*, $this as item()*) as item()* {
         let $thisValue := $f($this)
         let $highestValue := $f($highestSoFar[1])
         return
           if ($thisValue gt $highestValue)
             then $this
           else if ($thisValue eq $highestValue)
             then ($highestSoFar, $this)
           else $highestSoFar
       }, fn:head($seq), fn:tail($seq))
};</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126436</commentid>
    <comment_count>1</comment_count>
    <who name="Hans-Juergen Rennau">hrennau</who>
    <bug_when>2016-05-15 18:20:30 +0000</bug_when>
    <thetext>There is a second bug hidden in the examples eg:highest and eg:lowest:
the inline function expression passed to fn:fold-left is

   function($highestSoFar as item()*, $this as item()*) as item()* {...}

Note the second parameter:
   $this as item()*

which is incorrect - it should be
   $this as item()

(no occurrence indicator).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126477</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-05-23 11:48:27 +0000</bug_when>
    <thetext>Thanks for reporting it. The problem was fixed as part of the resolution of bug #28885.

*** This bug has been marked as a duplicate of bug 28885 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>