MathGroup Archive 2010

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

Search the Archive

Re: How to localize a symbol when using Manipulate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112622] Re: How to localize a symbol when using Manipulate?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 23 Sep 2010 04:22:41 -0400 (EDT)

On 9/22/10 at 1:58 AM, nma at 12000.org (Nasser M. Abbasi) wrote:

>I want to make a call to a lower level function which makes an
>expression (say build a polynomial in s) and returns it back to be
>displayed.

>I want this function to use a symbol, say s, to build the
>polynomial.

>The problem is how to localize the symbol itself so it is not
>global.

>Since one dose not declare things in Mathematica, (sometime I wish I
>could) I can't declare the s to be a symbol, but must just use it.

>Here is a simple example to show the problem:

>If one does not pass a symbol for a lower level function during the
>call to be used in constructing an expression, then the expression
>will have $nnnn added to it.

>Manipulate[process[n], {n, 2, 10},
>Initialization :>
>(process[n_] := Module[{s}, s^n])
>]

>If you run the above, the result shown will be s$nnn^2  where nnn is
>some number.


The simplest way I know to not get the s$nnn form created by
using Module is to use Block instead. That is

Manipulate[process[n], {n, 2, 10},
Initialization :>
     (process[n_] := Block[{s}, s^n])
]

will have display power of s rather than a power of s$nnn



  • Prev by Date: Limit of Hypergeometric2F1
  • Next by Date: Re: Summing above diagonal in a tensor
  • Previous by thread: How to localize a symbol when using Manipulate?
  • Next by thread: Re: How to localize a symbol when using Manipulate?