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

MathGroup Archive 2008

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

Search the Archive

Re: Instructions in for

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89403] Re: [mg89371] Instructions in for
  • From: "W_Craig Carter" <ccarter at mit.edu>
  • Date: Sun, 8 Jun 2008 02:34:02 -0400 (EDT)
  • References: <200806070659.CAA09938@smc.vnet.net>

Hello Alejandra,

On Sat, Jun 7, 2008 at 2:59 AM, Alejandra Lozada <alozih at gmail.com>
> QUESTION: how to introduce many instructions in for?
Here is an example that shows the use of semicolons.

For[ i=1, i<20, i++,
Print[i];
 Print[i^2];
 d= FactorInteger[i];
 Print[Length[d]]
 ]


Generally, you will get more flexible and faster code if you use Map,
Table, and Through type constructs rather than For.


-- 
W. Craig Carter


  • Prev by Date: Re: ContourPlot3D appearance
  • Next by Date: Re: Major problem with 6.0.2.1
  • Previous by thread: Instructions in for
  • Next by thread: Re: Instructions in for