Re: What is going on!?!

• To: mathgroup at smc.vnet.net
• Subject: [mg104751] Re: [mg104688] What is going on!?!
• From: Stern <nycstern at gmail.com>
• Date: Sun, 8 Nov 2009 06:50:29 -0500 (EST)
• References: <200911071146.GAA09847@smc.vnet.net>

```You will probably get a lot of answers to this. By including only a
space between the For[] expression and the x, you have multiplied
these two things together. x is, as you expect, worth 10, but the
For[] expression has no value. When you multiply these together, you
get 10 Null.

You can illustrate this by doing something like

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

In[]:= s

There will be no result, as the For[] expression itself has no value.

Also, though this seems to be just a test problem, whatever you're
trying to accomplish here may better be done with Table[] or, in the
really simple case, Range[].

Table[i, {i, 10}]

Range[10]

-Michael Stern
Merrin Capital Management

On Sat, Nov 7, 2009 at 6:46 AM, Joe Hays <joehays at vt.edu> wrote:
> 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: What is going on!?!
• Next by Date: Re: Function returns null
• Previous by thread: Re: What is going on!?!
• Next by thread: Re: What is going on!?!