Date: Jan 21, 2013 12:06 AM
Author: svkeeley@aol.com
Subject: Re: problem with append

> For[a = 2, a < 6, a++,
>
> For[b = 2, b < 6, b++,
>
> Appendto[rr = {}, a^b]]]
>
> rr



One thing wrong is that everytime through the loop, you reset rr to an empty set. The AppendTo statement should read "Appendto[rr, a^b]" with rr assigned to {} before the loop.

This works:

rr = {};
For[a = 2, a < 6, a++,
For[b = 2, b < 6, b++, AppendTo[rr, a^b]]];
rr

{4,8,16,32,9,27,81,243,16,64,256,1024,25,125,625,3125} In[9]:= rr = {};

So does this:

rr = {};
For[a = 2, a < 6, a++,
For[b = 2, b < 6, b++, rr = Append[rr, a^b]]];
rr

{4,8,16,32,9,27,81,243,16,64,256,1024,25,125,625,3125}