MathGroup Archive 2010

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

Search the Archive

Handle dynamic variables (any help appreciated)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108596] Handle dynamic variables (any help appreciated)
  • From: Janos Turelem <jturelem at gmail.com>
  • Date: Thu, 25 Mar 2010 04:22:22 -0500 (EST)

Dear All,

I am new to Mathematica and I am trying to handle a list which updates
dynamically (at the end of this email you will find an example of the
code). This gives me an error, since the list firstvar is actually NOT
a list (I checked its length, and it gives me 1, instead of 6). If I
assign := the value of  firstvar to another variable, then everything
works, but the programs behaves really weirdly.

Possibly, there is an easy and straightforward way to solve this
issue, but I do not know it.

Any help will be highly appreciated.

Thanks

doingsomething[m_, p_, _] := Abs[m -
Total[RotateLeft[ReplacePart[Array[0 &, Dimensions[m]], p -> 1], #] & /
@ {{0,0}}]]

Manipulate[
 Grid[{{firstvar = Dynamic[Flatten[inputstring]]}, {SeedRandom[seed];
    DynamicModule[{m = RandomInteger[{0, 1}, {1, q}], gg = {0, 0}},
     Dynamic@(If[gg == {0, 0}, {}, m = doingsomething[m, gg, q];
        gg = {0, 0}; inputstring = m;];
       Pane[TableForm[
         MapIndexed[
          Button["   ", gg = #2,
            ImageSize -> {250/(q + 1), 250/(q + 1)},
            Background -> {White, Black}[[1 + #1]]] &, m, {2}]], {450,
          200}, Alignment -> Center])]}, {ArrayPlot[
     CellularAutomaton[0, firstvar, 10]]}}], {{q, 6, "size"}, 3, 9,
  1}, {{seed, 1, "new game"}, 1, 1000, 1}, SaveDefinitions -> True]


  • Prev by Date: Re: Sort within self-defined procedure
  • Next by Date: Re: Sort within self-defined procedure
  • Previous by thread: Re: counting number of variables in an expression
  • Next by thread: How to pass additional parameters to the ticks function?