MathGroup Archive 2009

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

Search the Archive

Weird localization bug!

  • To: mathgroup at
  • Subject: [mg106009] Weird localization bug!
  • From: Derek Yates <yatesd at>
  • 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

(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

  • Prev by Date: Re: Replace and ReplaceAll -- simple application
  • Next by Date: Re: algebraic numbers
  • Previous by thread: Re: Creating a plot of multiple graphs - multiple scaled axis...
  • Next by thread: Re: Weird localization bug!