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.