MathGroup Archive 2007

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

Search the Archive

Re: Slider[] and Dynamic[] implementation details

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83978] Re: Slider[] and Dynamic[] implementation details
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 6 Dec 2007 02:39:02 -0500 (EST)
  • References: <fj0mqa$iil$1@smc.vnet.net>


Hi Otto,

see below, Daniel



Otto Murphy wrote:

> Hey all,

> 

> I'm curious about the workings of Mathematica 6's dynamic functionality.

> Specifically the interaction between Slider[] and Dynamic[] in this simple

> example:

> 

> Slider[Dynamic[x, (x = 1 - #) &]]

> Dynamic[x]

> 

> Okay so my first question involves removing the first embedded dynamic and

> leaving just the x, like so:

> 

> Slider[x]

> Dynamic[x]

> 



from the manual: Slider[Dynamic[x]] will reset the value of x when the 

slider is moved; Slider[x] will not.



> Intuitively, to me, the slider function should still be able to update the

> value of x and the dynamic should still be able to display those updated

> values. Like if slider were just like a normal function that updates the

> value of x in the kernel just like a new assignment statement would. BUT,

> this doesn't happen--X doesn't change. This makes me think there's some

> special mechanism here. Could someone explain it?

> 

> My second question has to do with the second argument to Dynamic. Again,

> intuitively, to me, it seems like when dynamic looks for an updated value of

> x, it uses that function to assign it it's new value. But this couldn't be

> completely true because it doesn't work like this:

> 

> 

> Slider[Dynamic[x]]

> Dynamic[Dynamic[x, (x = 1 - #) &]]

> 

> The dynamic display of x doesn't seem to use the function--it only works

> when it's in slider[]. Why is that?

First, I do not see any reason for a double "Dynamic". Second, how do 

you decide that: "The dynamic display of x doesn't seem to use the 

function". E.g. you can not simply say: Dynamic[x, (x = 1 - #) &], this 

would make a definition for Dynamic not x. To assign to x, you simply 

need to write x=...



> 

> I looked through the documentation and didn't see anything addressing these

> kinda picky questions, but I'm just darn curious. Although Mathematica isn't

> open source, I'm assuming there are plenty of people out there who are

> familiar with implementation details like these.

> 

> Thanks a lot for the help!

> 

> 




  • Prev by Date: Re: Adding coloured Polygon to a BarChart
  • Next by Date: Re: Re: FindInstance what inspite ?
  • Previous by thread: Slider[] and Dynamic[] implementation details
  • Next by thread: RE: Re: Geocoding using Mathematica