[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XQuery/XPath 3.1: Node List to Node Set ("distinct
> On 28 Dec 2021, at 23:54, Dimitre Novatchev dnovatchev@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > > $nodes[index-of($nodes ! generate-id(.), generate-id(.))[1]] > > This seems a candidate for "the shortest solution" and it shouldn't be inefficient, given a good optimizer: > It probably also gets a prize for the first practical use case of a filter expression where the predicate is numeric and has different values for different nodes in the input sequence. It's going to be O(n*m) unless index-of() is optimized to use some kind of index or hash lookup rather than a sequential search. That's assuming that the expression $nodes ! generate-id(.) gets loop-lifted; if it isn't, then it becomes O(n*n*m). Aesthetically, I find generate-id() ugly and it would be nice to avoid it. Michael Kay Saxonica
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|