MathGroup Archive 2002

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

Search the Archive

Re: Union

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33114] Re: Union
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sun, 3 Mar 2002 17:15:17 -0500 (EST)
  • References: <a5t1p2$64u$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Helge,

The following was posted to MG by Carl Woll, maybe it twas called
RemoveRepeats.
It appears in the Help Browser entry for Union in FurtherExamples


    UnsortedUnion[x_]:=Module[{f},f[y_]:=(f[y]=Sequence[];y);f/@x]

    UnsortedUnion[{5,4,3,4,1,6}]

        {5,4,3,1,6}


--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Helge Andersson" <helgea at inoc.chalmers.se> wrote in message
news:a5t1p2$64u$1 at smc.vnet.net...
> 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
>
>




  • Prev by Date: Re: Union
  • Next by Date: Re: creating functions with variable number of options
  • Previous by thread: Re: Union
  • Next by thread: creating functions with variable number of options