MathGroup Archive 2006

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

Search the Archive

Re: removing dublicates in lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63810] Re: removing dublicates in lists
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sun, 15 Jan 2006 05:43:24 -0500 (EST)
  • References: <dqabv9$14c$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Kent Holing schrieb:
> 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
> 

test = {{1, 2, 3}, {44, 56, 78}, {1, 2, 3}, a, b}

Union[test]
--> {a, b, {1, 2, 3}, {44, 56, 78}}

If you want to preserve the ordering of your list, have a look at 
http://mathworld.wolfram.com/UnsortedUnion.html

Peter


  • Prev by Date: Re: removing dublicates in lists
  • Next by Date: Re: removing dublicates in lists
  • Previous by thread: Re: removing dublicates in lists
  • Next by thread: Re: removing dublicates in lists