MathGroup Archive 2002

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

Search the Archive

Re: Union

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33119] Re: Union
  • From: peter weijnitz <pewei at algonet.se>
  • Date: Sun, 3 Mar 2002 17:15:23 -0500 (EST)
  • References: <a5t1p2$64u$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

something along these lines?
test[{a_,b_},{c_,d_}]:=c==d;
Map[Last,Union[Transpose[{Range[Length[v]],v}],SameTest->test]];
Where v is the vector. You can make a module of it all.

I thought I would have to sort the result of the Union part but it was not
necessary.
Peter W

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



  • Prev by Date: Re: Union
  • Next by Date: Re: Union
  • Previous by thread: Re: Union
  • Next by thread: Re: Union