MathGroup Archive 1999

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

Search the Archive

Re: ? Repeated Patterns ?

  • To: mathgroup at
  • Subject: [mg19016] Re: ? Repeated Patterns ?
  • From: Bruno Daniel <bruno.daniel at>
  • Date: Tue, 3 Aug 1999 13:44:50 -0400
  • Organization: University of Karlsruhe
  • References: <7n8nfc$>
  • Sender: owner-wri-mathgroup at

Hi DongGook 

Beware that ".." doesn't match the same expression, but the same
pattern, for example:

In[1]:={0,1,2,3} /. {x_Integer..}->{x}
Out[1]= {0,1,2,3}

Another problem in your approach is that all patterns except for the
last try to find the shortest match:

If you want to collaps general repetitions of arguments you can do
it this way (the pattern is applied repeatedly):

In[2]:={0,3,5,0,0,1,3,3,4} //.{a___,x_Integer,b___,x_,c___}->{a,x,b,c}

If you rather want to collapse subsequent repetitions:

In[3]:={0,3,5,0,0,1,3,3,4} //.{a___,x_Integer,x_,c___}->{a,x,c}

Yours sincerely

  • Prev by Date: Re: Discrete Convolution
  • Next by Date: Re: ? Repeated Patterns ?
  • Previous by thread: RE: HELP : Mathematica v4 producing erroneous results ! Mathematica3 worked fine...
  • Next by thread: Re: ? Repeated Patterns ?