MathGroup Archive 2010

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

Search the Archive

Manipulate with dynamic maximum on slider

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113558] Manipulate with dynamic maximum on slider
  • From: Arend <asluis at gmail.com>
  • Date: Tue, 2 Nov 2010 05:03:13 -0500 (EST)

I am a newbie at Mathematica and playing around with Manipulate.

My problem: I have two controls, one completely independent, the other
dependent on the results of a calculation in the body of Manipulate.

Here is my code (simplified from the actual use case for clarity):

Manipulate[
 SeedRandom[seed];
{rl, ll} = Module[{newNum = 10000, rList},
   rList = Reap[
      While[! PrimeQ[newNum],
       Sow[newNum = RandomInteger[{10000, 100000}]]]][[2, 1]];
 {rList, Length[rList]}];
 (* If[steps != ll, steps = ll]; *)
 Take[rl, steps],
 {{seed, 250}, 100, 400, 1, Appearance -> "Labeled"},
{{steps, ll}, 1,  Dynamic[ll], 1, Appearance -> "Labeled"}]

The issue is that after the user changes the value of seed, the steps
slider should be given a new maximum value (determined by the length
of the list generated by the While loop) and the steps slider should
be set to this maximum value. That is, after choosing a new seed, the
user should see the complete list by default.

I've read the four Mathematica tutorials on Dynamic/Manipulate, which
are wonderful, but perhaps a bit of information overload.

What simple thing am I missing here?

Thank you for your help!


  • Prev by Date: Re: It would be nice to have DiagonalMatrix accept a matrix as building
  • Next by Date: Re: Using the fonts available in the Format>Font menu as part of Style[]?
  • Previous by thread: How to change LineIndent for a cell or the notebook (edit Default.nb? edit core.nb? SeOptions[]?)
  • Next by thread: Re: Manipulate with dynamic maximum on slider