Re: rule based program for "Deleting repeated members of a list."
- To: mathgroup at smc.vnet.net
- Subject: [mg81973] Re: rule based program for "Deleting repeated members of a list."
- From: Steven Siew <siewsk at bp.com>
- Date: Mon, 8 Oct 2007 00:03:16 -0400 (EDT)
- References: <fe7j44$qga$1@smc.vnet.net>
On Oct 6, 7:05 pm, 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. s = {a, b, a, b, c, c, d, d, e, e, f, b, c, e, a} MyUnique[ list_ ] := Map[First, Split@Sort[list]] In[6]= MyUnique[s] Out[6]= {a,b,c,d,e,f}