[Bug 29080] array:members

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29080

--- Comment #4 from Christian Gruen <christian.gruen@gmail.com> ---
(In reply to Abel Braaksma from comment #3)
> (In reply to Michael Kay from comment #1)
> > Alternatively (1), an extension to FLWOR expressions that binds a variable
> > to each member in turn, as a sequence:
> > 
> > let $my-array := [(1,2,3), (4,5)]
> > for member $m in $my-array return count($m)
> > 
> > returns (3,2)
> I find this interesting and a welcome addition (I'm not quite sure I
> understand your 2nd proposal with lambda-expressions). If this is added, I
> suggest to make it orthogonal with maps, as looping though a map is just as
> useful as looping through an array (apart from the undefined order).
’

Personally, I would vote for including a simple function. It requires no FLWOR
expression and it should be no-brainer in terms of specification and
implementation. But I’m looking forward to more discussion on this.


> We tried, back in the day that maps were only a feature of XSLT 3.0.

Here the new magic of arrays would help out as well (the example is very
similar to my array:members proposal):

  (: Current representation in XQuery :)
  declare function map:values(
    $map as map(*)
  ) as array(*)* {
    map:for-each($map, function($key, $value) {
      [ $value ]
    })
  };

  let $m := map {'a' : (1,2,3), 'b' : (2,3,4)}
  for $v in local:values($m)
  return <hit>{ $v }</hit>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 10 June 2016 10:08:11 UTC