Weird localization bug!
- To: mathgroup at smc.vnet.net
- Subject: [mg106009] Weird localization bug!
- From: Derek Yates <yatesd at mac.com>
- Date: Wed, 30 Dec 2009 04:13:53 -0500 (EST)
I can't figure this out, and think it is a bug. I'm using Mathematica 7.0.0 and get the same behaviour on both Mac OS X (10.5.8) and on Windows XP. I want a function which creates a rule. The rule is of the form "manipulated input" -> "input". Here is my first attempt (I have simplified from what I really want to do, in order to illustrate the bug): (1) makerule[input_] :=(input /. a_Integer :> 2 a) -> input In: makerule[5] Out: 2a->5 (I expect to get 10->5) (2) makerule2[input_] := (input /. a_Integer :> 2 a)~myrule~input In: makerule2[5] Out: myrule[10,5] as expected Forcing an extra layer of localization seems to squash the bug: (3) makerule3[input_] :=Block[{inputcopy = input},(input /. a_Integer :> 2 a) -> inputcopy] In: makerule[5] Out: 10->5 Is it a bug, or have I misunderstood how the localization is meant to work?
- Follow-Ups:
- Re: Weird localization bug!
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: Weird localization bug!