W3C home > Mailing lists > Public > public-qt-comments@w3.org > January 2016

[Bug 29393] New: Include a convenience operator for applying a function to each item in a sequence

From: <bugzilla@jessica.w3.org>
Date: Tue, 26 Jan 2016 12:03:34 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29393-523@http.www.w3.org/Bugs/Public/>

            Bug ID: 29393
           Summary: Include a convenience operator for applying a function
                    to each item in a sequence
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: XQuery 3.1
          Assignee: jonathan.robie@gmail.com
          Reporter: dk@basex.org
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

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 ("a", "b", "c") 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:

  ("a", "b", "c") ! (. => upper-case())

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

  ("a", "b", "c") ==> upper-case()

This gets even more relevant if the expression is longer. Lets take the example
from the spec for the arrow operator at


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

  $item ! (. =>upper-case()=>normalize-unicode()=>tokenize("\s+"))

With a new operator this would change to


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==>f() is
equivalent to $s ! f(.) or $s ! (. => f())

You are receiving this mail because:
You are the QA Contact for the bug.
Received on Tuesday, 26 January 2016 12:03:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:57 UTC