Re: Unsorted Union

*To*: mathgroup at smc.vnet.net*Subject*: [mg61486] Re: [mg61434] Unsorted Union*From*: "David Park" <djmp at earthlink.net>*Date*: Wed, 19 Oct 2005 23:07:45 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Robert, This was one of Carl Woll's ingenious routines. The first time f hits a value y it establishes a definition but returns y. The next time it hits a y the definition already exists and it returns Sequence[]. An empty Sequence is simply elimited from a list of items. This is very fast but it does use some storage space to store all the definitions. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Robert Schoefbeck [mailto:schoefbeck at hep.itp.tuwien.ac.at] To: mathgroup at smc.vnet.net Hello all, in the help section i found the following thing: UnsortedUnion[x_] := Module[{f}, f[y_] := (f[y] = Sequence[]; y); f/@x] It does just what it says: UnsortedUnion[{a,c,b,d,a,b}]={a,c,b,d} (ordinary Union would Sort the result) my question is: How does the definition work? I know all the syntax and i have been using these concepts for for some time now. But i cant figure out what this definition does. Robert