       Re: how uncouple dynamic objects?

• To: mathgroup at smc.vnet.net
• Subject: [mg109451] Re: how uncouple dynamic objects?
• From: Christoph Lhotka <christoph.lhotka at univie.ac.at>
• Date: Tue, 27 Apr 2010 08:07:57 -0400 (EDT)
• References: <201004270804.EAA20272@smc.vnet.net>

```hello,

that's easy if you allow the definition of pure functions:

fplot[f_Function] := Manipulate[Plot[f[x + a], {x, -2, 2}], {a, 0, 2}]
f = Function[{x}, x^2];
fplot[f]
f = Function[{x}, x^3];
fplot[f]

I guess, that while in your approach only the head is passed to the
function and Mathematica therefore looks for the global downvalue of it
in my approach the function itself is passed to the Manipulate function.

chr

On 27/04/2010 10:04, Murray Eisenberg wrote:
> Here's a simple example of a more complicated situation where I define a
> function that takes a function as argument and uses Manipulate to
> produce its output:
>
>     fplot[f_]:= Manipulate[
>                   Plot[f[x+a],{x,-2,2}],
>                 {a,0,2}]
>     f[x_]:= x^2
>     fplot[f]
>
>     f[x_]:=x^3
>     fplot[f]
>
> When I execute the second definition (with x^3) of f, it automatically
> changes the f used in the still-displayed output from the first call to
> fplot.
>
> How can I isolate the two instances -- and yet still use the same name
> for the two different functions?  (Or is this not possible?)
>
> Clearly this is an issue of the dynamic structure underlying
> Manipulate, and I'm willing to use a "direct" definition using a
> Dynmaic variable a with a control instead of the simpler
> Manipulate. But of course I'd prefer to be able to do it with
> Manipulate.
>
>

```

• Prev by Date: Re: Database memory usage
• Next by Date: Re: problems with NMinimize
• Previous by thread: how uncouple dynamic objects?
• Next by thread: Re: how uncouple dynamic objects?