[Date Index]
[Thread Index]
[Author Index]
Re: DynamicModule Pure Function
*To*: mathgroup at smc.vnet.net
*Subject*: [mg121801] Re: DynamicModule Pure Function
*From*: DrMajorBob <btreat1 at austin.rr.com>
*Date*: Mon, 3 Oct 2011 04:21:21 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*References*: <201110020637.CAA28048@smc.vnet.net>
*Reply-to*: drmajorbob at yahoo.com
The default range of a slider is 0 to 1. In your example, BOTH sliders
range from 0 on the left to 1 on the right.
The first slider has value Dynamic@x, so changing x moves the slider, and
moving the slider also changes x. The second slider generally has value 1
- x (the first argument of that Slider), so moving the first slider moves
the second.
The second argument of the second slider is a pure function whose argument
(#) is the numerical value of the slider, as determined by where you drag
the slider with the cursor. (When you're NOT dragging it, the pure
function is not invoked, and # has no value.) When you drag the second
slider, the pure function sets x equal to 1 - #, or 1 minus the value of
the second slider.
Changing x moves the first slider, so moving the second slider moves the
first.
Whichever slider you're moving, 1 - x is the mirror image of x, so the
sliders are "inverse" to one another.
Bobby
On Sun, 02 Oct 2011 01:37:19 -0500, Don <donabc at comcast.net> wrote:
> In the Wolfram tutorial "Introduction to Dynamic"
> (tutorial/IntroductionToDynamic)
> there is the following example approximately halfway into the tutorial:
>
> DynamicModule[{x = 0}, {Slider[Dynamic[x]],
> Slider[Dynamic[1 - x, (x = 1 - #) &]]}]
>
>
> The explanation that Wolfram gives for why this works (i.e. the second
> Slider is the inverse function of the first Slider) is unintelligible to
> me. Can anyone explain in plain, simple English (no jargon) what is
> going on here?
>
> For example, when x = 0.25 the second slider has to be at position
> 0.75. It can't update 1-x directly since
> 1-x cannot be set to a value. Of course, this
> is true, but it doesn't explain why the pure function is the solution.
>
>
> If x = 0.25, this implies that the # is equal to 0.75 since x = 1 - #.
> But, how did the system know that # = 0.75? Where did the 0.75 come
> from?
>
>
> To put it another way, I am use to the # being a placeholder in pure
> functions that ranges over a
> set of values. For example, in Select[list, # > 0 &], the # ranges over
> all the elements of list. What is # in the pure function of the second
> Dynamic ranging over and how does it come up with 0.75 as a value for #?
>
> Thank you in advance for any clear explanations you can give me.
>
--
DrMajorBob at yahoo.com
Prev by Date:
**Re: Simple fractal**
Next by Date:
**Re: Simple fractal**
Previous by thread:
**DynamicModule Pure Function**
Next by thread:
**Re: DynamicModule Pure Function**
| |