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(_at_)saxonica(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--