Hi Micheal, Agreed, it could be implemented as a user-defined function (although this particular solution currently throws an error in eXist). However, what bothers me is that fn:index-of(1,2,[3,4], 3) may lead to unexpected results, because the array is flattened. I get the impression that array-specific semantics are sacrificed here, where in other cases they aren't, and the dividing line is still unclear me.
Thanks, Wouter 2015-06-26 14:16 GMT+02:00 Michael Kay <[email protected]>: > I would think both of these could be implemented as user-defined functions > but it’s hard to know without seeing a specification: saying you want a > function called array:index-of() is not very informative unless you explain > exactly what you want the function to do. > > If it’s to behave like fn:index-of() then you can write it as > > array:index-of($array, $value) { > (1 to array:size($array))[ $array(.) = $value ] > } > > which is hardly a great hardship to write as a user-defined function. > > > Michael Kay > Saxonica > > On 26 Jun 2015, at 12:18, W.S. Hager <[email protected]> wrote: > > Hello, > > I've been working with the recent xquery 3.1 implementation in the develop > branch eXist-db. I encountered some cases that were quite hard to work > around: > > - the lack of array:index-of() > - the lack of the iterator index in arrayfor-each and related higher-order > functions > > Perhaps someone of the workgroup is available to discuss those cases. > > Thanks, > Wouter > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > _______________________________________________ > [email protected] > http://x-query.com/mailman/listinfo/talk > > > -- W.S. Hager Lagua Web Solutions http://lagua.nl
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
