Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: rule based program for "Deleting repeated members of a list."

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81992] Re: rule based program for "Deleting repeated members of a list."
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 8 Oct 2007 02:07:24 -0400 (EDT)
  • References: <fe7j44$qga$1@smc.vnet.net>

Sorry,

I read the news offline but forgot to load sunday's postings.

The fastest _rule-based_ solution I got is (with s being the large list 
from my last posting):

RepeatRemover =
    (Partition[#1, 2, 1, {1, 1}, "foo"] /.
       {x_, x_} -> Sequence[])[[All,1]] & ;
AbsoluteTiming[s2 = RepeatRemover[s]; ][[1]]
---> 0.015625 Second

which is 4750 times faster than the approach using ReplaceRepeated.

Peter

mumat schrieb:
> Hi,
> 
> I have a list s={a,b,c,c,d,e,e,f,g,g,g,h,a,b};
> 
> I need to write a program so that it reads the list and ignors
> repeated elements; so it outputs the following:
> 
> RepeatRemover[s]={a,b,c,d,e,f,g,h,a,b};
> 
> I am looking for a rule-based program to do this!
> 
> Any help would be greatly appreciated.
> 
> C.S.
> 
> 


  • Prev by Date: Re: rule based program for "Deleting repeated members of a list."
  • Next by Date: Re: Mathematica Numerical Integration and For Loop
  • Previous by thread: Re: Re: rule based program for "Deleting repeated members
  • Next by thread: Re: Re: rule based program for "Deleting repeated members of a list."