MathGroup Archive 2006

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

Search the Archive

Re: removing dublicates in lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63811] Re: removing dublicates in lists
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 15 Jan 2006 05:43:24 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <dqabv9$14c$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Kent Holing wrote:
> removeRepetitions[L_] := Fold[If[#2==Last[#1],#1,Append[#1,#2]]&,{First[L]},Rest[L]] successfully removes dublicates in lists like {1,2,2,3,6}.
> Is it an easy way to extend the functionality of this function such that it works with lists like
> {{1,2,3},{44,56,78},{1,2,3},...} removing dublicate elements such that {1,2,3}?
> Kent Holing
> NORWAY
> 
Hi Kent,

Try the built-in function *Union* 
(http://documents.wolfram.com/mathematica/functions/Union).

In[1]:=
Union[{1, 2, 2, 3, 6}]

Out[1]=
{1, 2, 3, 6}

In[2]:=
Union[{{1, 2, 3}, {44, 56, 78}, {1, 2, 3}}]

Out[2]=
{{1, 2, 3}, {44, 56, 78}}

Best regards,
/J.M.


  • Prev by Date: Re: removing dublicates in lists
  • Next by Date: Re: How to create {{x1,y1}, ..., {xn,yn}} data from {x1,...,xn} and {y1, ..., yn}
  • Previous by thread: Re: removing dublicates in lists
  • Next by thread: Re: Using FindRoot with an equation that includes Maximize