|
Subject: Re: [xsl] XQuery/XPath 3.1: Node List to Node Set ("distinct nodes") From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 28 Dec 2021 23:55:24 -0000 |
Actually, O(n*m) where n is the number of input nodes and m the number of
output (distinct) nodes. So it's likely to be perfectly viable for large n,
but not for large m.
Michael Kay
Saxonica
> On 28 Dec 2021, at 23:47, Michael Kay mike@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> For a solution that delivers distinct nodes in order of first appearance, my
preference would be
>
> $nodes => fold-left((), function($all, $this) {if ($all intersect $this)
then $all else ($all, $this)})
>
> It's likely to be O(n^2) in most implementations, whereas Martin Honnen's
solution is probably O(n log n) -- but this one is XPath rather than XQuery,
and feels more elegant.
>
> 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, Michael Kay mike@xxx |
| Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn | Date | Re: [xsl] XQuery/XPath 3.1: Node Li, Michael Kay mike@xxx |
| Month |