Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13232 > unrolled thread
| Started by | bsyehuda@gmail.com |
|---|---|
| First post | 2013-01-21 05:06 +0000 |
| Last post | 2013-01-21 05:06 +0000 |
| Articles | 1 — 1 participant |
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 bsyehuda@gmail.com - 2013-01-21 05:06 +0000
| From | bsyehuda@gmail.com |
|---|---|
| Date | 2013-01-21 05:06 +0000 |
| Subject | Re: problem with append |
| Message-ID | <kdiida$ncc$1@smc.vnet.net> |
There are some errors here
1. The function name is AppendTo (with capital T) - Mathematica is case
sensitive
2. Even this would not help, since r={} in the body of AppendTo refers to
the return value of the assignment rather than to rr
Combining 1 and 2 above results with the immediate correction
rr = {};
For[a = 2, a < 6, a++, For[b = 2, b < 6, b++, AppendTo[rr, a^b]]]
rr
But any decent Mathematica programmer is aware of how inefficient Append,
AppendTo, Prepend, PrependTo and Insert are
You have many other ways, which are more efficient. Note that Do and For
return Null, and what you do is adopting the concept of side effects to
generate lists - a highly inefficient way in Mathematica
Read the documentation on
Table, Array, Flatten
to enhance your programming in Mathematica
yehuda
On Sun, Jan 20, 2013 at 8: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
>
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web