Re: Keeping order with Union
- To: mathgroup at smc.vnet.net
- Subject: [mg32608] Re: Keeping order with Union
- From: Daniel Reeves <dreeves at flip.eecs.umich.edu>
- Date: Thu, 31 Jan 2002 01:45:37 -0500 (EST)
- Organization: University of Michigan Engineering
- References: <a38bd0$2n$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I think the following linear time algorithm was Allen Hayes's idea: removeDups[l_] := Block[{i}, i[n_] := (i[n] = Sequence[]; n); i /@ l] --- \/ FROM Dave Snead AT 02.01.30 08:37 (Today) \/ --- > I'd like a function that throws out duplicate entries in a list and keeps > the > original list order. (when it sees 2 equal entries it throws out the one > that is later in the list). I'd use Union, but it sometimes changes the > order of the elements in the list. What's the tersest way to do this? > Thanks in advance, > Dave Snead > > > >