Re: rule based program for "Deleting repeated members of a list."
- To: mathgroup at smc.vnet.net
- Subject: [mg81930] Re: rule based program for "Deleting repeated members of a list."
- From: markholtuk at googlemail.com
- Date: Sun, 7 Oct 2007 05:26:37 -0400 (EDT)
- References: <fe7j44$qga$1@smc.vnet.net>
I'm sure there are more elegant ways of doing what you want, but here
is my take:
In[1]:=list={a,b,c,c,d,e,e,f,g,g,g,h,a,b};
Delete[list, Position[ ListConvolve[ {-1,1}, list], 0]]
Out[2]={a,b,c,d,e,f,g,h,a,b}
HTH,
Mark
Mark R. Holt, BA, PhD,
Room 3.28
Molecular Cardiology,
Cardiovascular Division and
Randall Division of Cell and Molecular Biophysics,
New Hunt's House,
King's College London,
Guy's Hospital Campus,
LONDON, SE1 1UL.
Phone: +44 20 7848 6438
Fax: +44 20 7848 6435
On Oct 6, 10:05 am, mumat <csar... at gmail.com> wrote:
> 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.