Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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)? –  Yves Klett Aug 15 '13 at 15:55
    
@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! –  tjm167us Aug 15 '13 at 16:24

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer
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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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