MathGroup Archive 2004

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

Search the Archive

Re: Select from a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49884] Re: [mg49856] Select from a list
  • From: Ken Levasseur <klevasseur at mac.com>
  • Date: Thu, 5 Aug 2004 09:20:57 -0400 (EDT)
  • References: <200408041446.KAA20166@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

One way to do it is with ReplaceRepeated (//.):

In[1]:=
a = {1, 1, 2, 2, 4, 6, 6, 8, 8, 9}

Out[1]=
{1, 1, 2, 2, 4, 6, 6, 8, 8, 9}

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

Out[2]=
{1, 2, 4, 6, 8, 9}


Ken Levasseur
Math. Sci.
UMass Lowell


On Aug 4, 2004, at 10:46 AM, Feng-Yin Chang wrote:

> Hi everyone,
>
>    Does anyone have an idea to drop the repeating elements in one list?
>    The list was built in sequence,fortunately.
>
>    for example,
>    from a={1,1,2,2,4,6,6,8,8,9}
>    to a1={1,2,4,6,8,9}
>
>
>   The purpose is to avoid the one-to-many mapping problem in my case.
>
> Feng-Yin Chang,
> Institute of Physics,NCTU,Taiwan
>


  • Prev by Date: Re: Select from a list
  • Next by Date: Problem with eval. of neg. cube root of neg. #
  • Previous by thread: Re: Select from a list
  • Next by thread: Re: Select from a list