Subject: Re: [xsl] XQuery/XPath 3.1: Node List to Node Set ("distinct nodes") From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 29 Dec 2021 00:10:30 -0000 |
> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn | Thread | Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn |
Re: [xsl] XQuery/XPath 3.1: Node Li, Michael Kay mike@xxx | Date | Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn |
Month |