MathGroup Archive 2007

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

Search the Archive

Re: Rule and Module not working together

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77945] Re: Rule and Module not working together
  • From: Szabolcs <szhorvat at gmail.com>
  • Date: Wed, 20 Jun 2007 05:33:55 -0400 (EDT)
  • Organization: University of Bergen
  • References: <200706181107.HAA19846@smc.vnet.net> <f58f4g$9l7$1@smc.vnet.net>

Carl Woll wrote:
> Steven Siew wrote:
> 
>> On Mathematica 5.2, I tried to write a function which applies the rule
>> Log[A_] + Log[B_] -> Log[A * B] but somehow it does not work as I
>> expected.
>>  
>>
> 
> Use Log[A_] + Log[B_] :> Log[A B] instead.
> 
> On another note, there is no need to use Return in your code below. The 
> last expression in a Module is automatically returned.
> 
> Carl Woll
> Wolfram Research

I understand that Module[] is not necessary here, and that RuleDelayed 
solves the problem, but I still do not see why aren't variables renamed 
when they are inside a Rule and a Pattern (as I described in a previous 
reply to this thread), and why are both Pattern and Rule required for this?

Is this a bug?

Or is it the intended behaviour?  If it is the intended behaviour, could 
someone please explain why is it necessary/useful, and how does this 
scoping mechanism work exactly?

It seems that I will never be able to understand the Mathematica 
language well enough to predict this kind of behaviour ... :-(

Szabolcs


  • Prev by Date: Button on a palette to create new text cells
  • Next by Date: Re: Mathematica 6 and normal distribution?
  • Previous by thread: Re: Rule and Module not working together
  • Next by thread: Re: Rule and Module not working together