Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Difference between ; and , in for loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113917] Difference between ; and , in for loop
  • From: graser <graser at gmail.com>
  • Date: Thu, 18 Nov 2010 07:03:57 -0500 (EST)

Hi Mathematica Group,

Would anyone explain me the difference between ; and , in conditional
loop like for loop?
For example,

1) For[i = 1, i < 2, i++; Print[i]]
Answer is 2

But

2)  For[i = 1, i < 2, i++, Print[i]]
The Answer is 1

Why does first loop get  2 instead of 1?

Thanks!





  • Prev by Date: How to Clear All Variables in Current Cell
  • Next by Date: Re: Mathematica 8: first impressions
  • Previous by thread: Re: How to Clear All Variables in Current Cell
  • Next by thread: Re: Difference between ; and , in for loop