Re: What is going on!?!

• To: mathgroup at smc.vnet.net
• Subject: [mg104734] Re: [mg104688] What is going on!?!
• From: "David Park" <djmpark at comcast.net>
• Date: Sun, 8 Nov 2009 06:46:57 -0500 (EST)
• References: <23886295.1257594705714.JavaMail.root@n11>

```I think it is generally a good technique to put multiple statements in one
cell, but you need to insert a line return (Enter) before the last x. That
is, the last x should be on a separate line - but in the same cell.

Because of the last ";" the For statement returned a Null, which would
normally suppress output from a line, but you multiplied it by x and that's
why you got 10 Null.

Generally, in Mathematica, it is better to use Procedural programming
statements. Something similar could be done with:

x = 0;
Do[x++, {10}]
X

x = 0; numbers = {x};
While[x < 10, x = x + 1; numbers = Join[numbers, {x}]]
numbers

David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

From: Joe Hays [mailto:joehays at vt.edu]

Can anyone tell me why the output is not a simple "10" instead of "10 Null"?

In[3]:= x = 0;
For[i = 1, i <= 10, i++,
x = x + 1;
] x

Out[4]= 10 Null

```

• Prev by Date: Re: Function returns null
• Next by Date: Re: What is going on!?!
• Previous by thread: Re: What is going on!?!
• Next by thread: Re: What is going on!?!