MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Keeping order with Union

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32606] Re: [mg32590] Keeping order with Union
  • From: Mianlai Zhou <lailai at nikhef.nl>
  • Date: Thu, 31 Jan 2002 01:45:33 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, Dave, this is easy. Just use:

MyUnion := (# //. {a___, b_, c___, b_, d___} :> {a, b, c, d}) &

and MyUnion[{a,b,c,d,d,f,c,e}] will give {a,b,c,d,f,e}, for example.

Good luck!

Mianlai Zhou
Theory Group, NIKHEF
Amsterdam, The Netherlands

On Wed, 30 Jan 2002, Dave Snead wrote:

> 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
> 
> 
> 
> 



  • Prev by Date: Re: Keeping order with Union
  • Next by Date: Re: Keeping order with Union
  • Previous by thread: Re: Keeping order with Union
  • Next by thread: Re: Keeping order with Union