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: [mg82066] Re: rule based program for "Deleting repeated members of a list."
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Thu, 11 Oct 2007 00:17:52 -0400 (EDT)
  • References: <fe7j44$qga$1@smc.vnet.net> <fea9ju$k4g$1@smc.vnet.net> <fei2kq$qa4$1@smc.vnet.net>

Jean-Marc Gulliet wrote:
> I was wandering why you used b and d as pattern name with a condition on 
> them rather than b and c, but I realized that when using c as pattern 
> name in place of d the replacement fails.
> 
> In[1]:= s = {a, b, c, c, d, e, e, f, g, g, g, h, a, b};

Hi,

You probably noticed this by now, but on the following line there should 
be {a,b,d} instead of {a,b,d}

> s //. {a___, b_, c_, d___} :> {a, b, c} /; b == c

---------------------------------------^

s //. {a___, b_, c_, d___} :> {a, b, d} /. b === c

> s //. {a___, b_, d_, e___} :> {a, b, e} /; b == d
> 
> Out[2]= {a, b, c, c}
> 
> Out[3]= {a, b, c, d, e, f, g, h, a, b}
> 
> Does anyone know why?
> 

-- 
Szabolcs


  • Prev by Date: Re: Matrices
  • Next by Date: Re: Matrices
  • Previous by thread: Re: Re: Re: rule based program for "Deleting repeated members of a list."
  • Next by thread: Re: rule based program for "Deleting repeated members of a list."