MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: What is going on!?!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104763] Re: What is going on!?!
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Sun, 8 Nov 2009 07:27:19 -0500 (EST)
  • References: <hd3ml1$9in$1@smc.vnet.net>

Joe Hays schrieb:
> 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


you are multiplying the result of the For loop with x, which happens to
be 10. And from the documentation:
"Unless an explicit Return is used, the value returned by For is Null."
which is why the result of the loop times 10 is 10*Null...

hth,

albert


  • Prev by Date: Re: Function returns null
  • Next by Date: Another Monitor problem
  • Previous by thread: Re: What is going on!?!
  • Next by thread: Complex solutions to simple equations