Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13225 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2013-01-21 05:05 +0000 |
| Last post | 2013-01-23 04:18 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: problem with append Bob Hanlon <hanlonr357@gmail.com> - 2013-01-21 05:05 +0000
Re: problem with append David Bailey <dave@removedbailey.co.uk> - 2013-01-23 04:18 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2013-01-21 05:05 +0000 |
| Subject | Re: problem with append |
| Message-ID | <kdiibf$n7m$1@smc.vnet.net> |
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@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
>
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-01-23 04:18 +0000 |
| Message-ID | <kdnoaq$727$1@smc.vnet.net> |
| In reply to | #13225 |
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@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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web