Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Keeping order with Union

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32595] Re: [mg32590] Keeping order with Union
  • From: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>
  • Date: Thu, 31 Jan 2002 01:45:17 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

This is the question that in 1999 elicited a real jem of a solution from 
Carl Woll:

OrderedUnion[li_]:=Block[{i,Sequence},
     i[n_]:=(i[n]=Sequence[];n);i/@li]


Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/


On Wednesday, January 30, 2002, at 05:19  PM, 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: How to get rid of this format
  • Previous by thread: Re: Keeping order with Union
  • Next by thread: RE: Keeping order with Union