How do I get the delta between two lists?

For example givenx: 1+ til 10y: 9 8 7 6 5How would I producez: 1 2 3 4 10Which is x less any common elements in y

charset=us-ascii
Message-Id: <746A244D-4BFA-49E0-8561-3D799662DCF5@gmail.com>
Cc: Kdb+ Personal Developers
X-Mailer: iPhone Mail (9A405)
From: Attila Vrabecz <attila.vrabecz>
Subject: Re: [personal kdb+] How do I get the delta between two lists?
Date: Thu, 17 Nov 2011 07:32:14 +0000
To: “personal-kdbplus@googlegroups.com

except

Attila</attila.vrabecz>

ha - interesting, i’ve been poking into ways of solving intersection
(“except” being “not intersection”). the naive way to find
intersection is to iterate through x and see if x in y. a small
optimization is to choose the smaller list as x, but it’s still O(n).

if there is a sorting on both lists, there are algorithms of O(log n)
(or thereabouts) - the algorithms are not particularly ingenious and
you’ll probably see that if you find the literature, it works like you
expected it would.