1
$\begingroup$

I want to create a table as shown below so that the steps from the first item to the second item, and the second item to the third item, etc. can be animated.

Example Output

I am not at liberty to post tested code right now, but I think this would work:

Table[Grid[Partition[Riffle @@ {Range[n],Range[n]^2},2]], {n,1,3}]

Does anyone have a cooler way of doing this? And by cooler, I mean a way that doesn't require the use of Riffle and Partition (by creating something that is properly formatted for Grid to begin with).

Also, if the above code doesn't work, can someone please tell me why?

$\endgroup$
2
  • $\begingroup$ Where is the problem with posting the "tested code"? Do you have a copy of Mathematica (BTW your example works, but all entries are centered vertically)? $\endgroup$
    – Yves Klett
    Aug 15 '13 at 15:55
  • $\begingroup$ @YvesKlett: I thought of the solution while at work (where I don't have Mathematica). Thanks for checking the accuracy of my example - I'm not concerned about the centering since this is easily remedied! $\endgroup$
    – tjm167us
    Aug 15 '13 at 16:24
1
$\begingroup$

If I am understanding your intention:

n = 6;

start = Array[{#, #^2} &, n];

hidden = Map[Invisible, start, {2}];

frames = Table[Grid @ PadRight[Take[start, x], n, hidden], {x, n}];

Export["tabletext.gif", frames, "DisplayDurations" -> 0.3]

enter image description here

$\endgroup$
1
$\begingroup$
Manipulate[
 Module[{i, j, r},
  r = Table[Flatten@Table[If[j < i, {0, 0}, {i, i^2}], {j, n}], {i, n}] /.0 -> "";
  Grid[r, Frame -> All, FrameStyle -> LightGray, Spacings -> {.5, .5}]
  ],
 {{n, 6, "how big?"}, 3, 20, 1, Appearance -> "Labeled"}
 ]

enter image description here

To export the manipulate to animated GIF, you can use Vitaliy Kaurov ManToGif program http://community.wolfram.com/groups/-/m/t/86994?p_p_auth=4rPWkLpF

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.