Re: Union
- To: mathgroup at smc.vnet.net
- Subject: [mg33118] Re: Union
- From: Erich Mueller <emueller at mps.ohio-state.edu>
- Date: Sun, 3 Mar 2002 17:15:22 -0500 (EST)
- Organization: Ohio State University
- References: <a5t1p2$64u$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Look in the help browser under union, and you will find the following code
UnsortedUnion[x_] := Module[{f}, f[y_] := (f[y] = Sequence[]; y); f /@ x]
On Sun, 3 Mar 2002, Helge Andersson wrote:
> Hello,
>
> I wonder if it is possible to disable the sort-function of the Union command?
> If not, can someone give me a short and nice procedure f, that can get the
> union of a list with the original order preserved (the first apperance
> should be left in the list). I'm not interrested in Do-loops solutions and
> and similar procedures (I can do that myself)
>
> example
> in:
> f[{5,4,3,4,1,6}]
>
> out:
> {5,4,3,1,6}
>
> Thanks in advance
> /Helge Andersson
>
>
>