MathGroup Archive 1997

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

Search the Archive

Re: Bug in pattern matching?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8730] Re: [mg8722] Bug in pattern matching?
  • From: Olivier Gerard <jacquesg at pratique.fr>
  • Date: Sat, 20 Sep 1997 22:27:58 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

At 08:48 +0200 97.09.19, Peter Str=96mbeck wrote:
>
> Doing this in a pattern matching statement produces a totally different
> result:
>
> In[5]:=3D
> ls/.{first_, middle___, last_}\[Rule] {{first},C {middle},{last}}
> Out[5]=3D
> {{a[0]},{C a[1] a[2] a[3] a[4]},{a[5]}}
>
> The middle list now contains a completely different result than Out[4]!
>
> Can anyone please explain this to me?
>
> /Peter Str=96mbeck

This is not a bug, Peter, this is a feature. When you define
rules, the right hand side is evaluated. This explain the result.

You should use RuleDelayed  (:>)  (This is not a smilie, or is it ?)
This way, the right hand side will be evaluated when the pattern is
applied so Times will be threaded on the whole middle list.


Hope this helps

Olivier.

(PS: curious you didn't have an answer from WRI support. I am sure
they could find this out. Are you registered ?)





  • Prev by Date: Correction to orig message
  • Next by Date: Re: Bug in pattern matching?
  • Previous by thread: Re: Bug in pattern matching?
  • Next by thread: Re: Bug in pattern matching?