Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5328 > unrolled thread

Re: DynamicModule Pure Function

Started byDrMajorBob <btreat1@austin.rr.com>
First post2011-10-03 08:24 +0000
Last post2011-10-03 08:24 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: DynamicModule Pure Function DrMajorBob <btreat1@austin.rr.com> - 2011-10-03 08:24 +0000

#5328 — Re: DynamicModule Pure Function

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-10-03 08:24 +0000
SubjectRe: DynamicModule Pure Function
Message-ID<j6brft$8li$1@smc.vnet.net>
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@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@yahoo.com

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web