<?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>29393</bug_id>
          
          <creation_ts>2016-01-26 12:03:34 +0000</creation_ts>
          <short_desc>Include a convenience operator for applying a function to each item in a sequence</short_desc>
          <delta_ts>2016-01-26 19:36:35 +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>XQuery 3.2 Use Cases and Requirements</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dirk Kirsten">dk</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>mike</cc>
          
          <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>124712</commentid>
    <comment_count>0</comment_count>
    <who name="Dirk Kirsten">dk</who>
    <bug_when>2016-01-26 12:03:34 +0000</bug_when>
    <thetext>XQuery 3.1 introduces the arrow operator to apply a function to an item in a much more readable way. In the same spirit, I would like to apply a function to items in a sequence in such a nice and easily readable way. 

Suppose, we have a sequence (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) and we want to get a sequence of upper-case letters as a result. So using the ! operator we can get each item in the sequence and using the arrow operator we can apply the upper-case function. This will result in the following code:

  (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) ! (. =&gt; upper-case())

which isn&apos;t really easier readable anymore because of the required parenthesis. It would be much nicer if we could add an operator, lets say ==&gt;, which would apply the function for each item in the sequence, so we would simply write:

  (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) ==&gt; upper-case()

This gets even more relevant if the expression is longer. Lets take the example from the spec for the arrow operator at https://www.w3.org/TR/2014/WD-xquery-31-20140424/#id-arrow-operator:

  tokenize((normalize-unicode(upper-case($string))),&quot;\s+&quot;)

Suppose, instead of a $string we have a $sequence. Currently, we would have to write:

  $item ! (. =&gt;upper-case()=&gt;normalize-unicode()=&gt;tokenize(&quot;\s+&quot;))

With a new operator this would change to

  $item==&gt;upper-case()=&gt;normalize-unicode()=&gt;tokenize(&quot;\s+&quot;)

which removes difficult to read and nested parenthesis.

So to sum up, this double arrow operator is a postfix operator that applies a function to each item in a seuqnece, using each item as the first argument to the function.] If $s is a sequence and f() is a function, then $s==&gt;f() is equivalent to $s ! f(.) or $s ! (. =&gt; f())</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124718</commentid>
    <comment_count>1</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2016-01-26 17:33:33 +0000</bug_when>
    <thetext>I&apos;m moving this to 3.2 (future versions).  It&apos;s too late for the current CR.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124720</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-01-26 19:36:35 +0000</bug_when>
    <thetext>There&apos;s always

(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) =&gt; for-each(uppercase#1)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>