Re: removing dublicates in lists
- To: mathgroup at smc.vnet.net
- Subject: [mg63816] Re: removing dublicates in lists
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 15 Jan 2006 05:43:28 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 1/14/06 at 2:32 AM, KHO at statoil.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 There already exists a built-in function that accomplishes this, i.e. 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}} -- To reply via email subtract one hundred and four