Re: problem with append

• To: mathgroup at smc.vnet.net
• Subject: [mg129556] Re: problem with append
• From: David Bailey <dave at removedbailey.co.uk>
• Date: Tue, 22 Jan 2013 23:19:08 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net
• References: <20130120062148.0CB436854@smc.vnet.net> <kdiibf\$n7m\$1@smc.vnet.net>

```On 21/01/2013 05:05, Bob Hanlon wrote:
> rr = {};
> For[a = 2, a<  6, a++,
>      For[b = 2, b<  6, b++,
>        AppendTo[rr, a^b]]]
>
> rr
>
> Or
>
> rr = Table[a^b, {a, 2, 5},
>      {b, 2, 5}]//Flatten
>
> Or
>
> rr = Table[a^Range[2, 5],
>      {a, 2, 5}]//Flatten
>
>
> Bob Hanlon
>
>
> On Jan 20, 2013, at 1:21 AM, Paolo cachecho<paolocach at gmail.com>  wrote:
>
>> hello i am new to mathmatica.i have the following problem if anyone could help.
>>
>> For[a = 2, a<  6, a++,
>>     For[b = 2, b<  6, b++,
>>   Appendto[rr = {}, a^b]]]
>> rr
>>
>> but rr remains empty. how can i solve this
>> thank you
>>
>
I would like to add that I never use AppendTo, but simply Append:

rr=Append[rr,a^b];

This slightly longer form amounts to the same thing internally, and is
much clearer to read, since few Mathematica functions work by changing
their arguments (except those that are normally written as operators, = , := , etc.)

David Bailey
http://www.dbaileyconsultancy.co.uk

```

• Prev by Date: Re: Mathematica and Lisp
• Next by Date: Solving Ï(x)=n, where Ï(x) is Euler's totient func
• Previous by thread: Re: problem with append
• Next by thread: Re: problem with append