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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81935] Re: [mg81917] rule based program for "Deleting repeated members of
  • From: adriano.pascoletti at dimi.uniud.it
  • Date: Sun, 7 Oct 2007 05:29:12 -0400 (EDT)

> 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.
>
>
>
In my previous reply I didn't include what C.S. was looking for:

In[8]:= s //. {pre___, x_, x_, post___} :> {pre, x, post}

Out[8]= {a, b, c, d, e, f, g, h, a, b}

I included only the more efficient solution

In[9]:= First /@ Split[s]

Out[9]= {a, b, c, d, e, f, g, h, a, b}

Adriano Pascoletti



  • Prev by Date: Re: rule based program for "Deleting repeated members of
  • Next by Date: Re: rule based program for "Deleting repeated members of a list."
  • Previous by thread: Re: rule based program for "Deleting repeated members of
  • Next by thread: Re: Riffle[] accepts only lists. Why?