>______________________________________________
>QUESTION: how to introduce many instructions in for?
>______________________________________________
>In C++ it is possible to use while/for and
>include many instructions:
>for( i=0; i<n; i++ ){
>instructions,
>as many as you
>like }
>In Mathematica, one instruction (Print) :
>For[ i=1, i<n, i++, Print[i] ]
>how can I include more instructions?
Use a compound expression. Look up compound expression in the
Documentation Center. As an example;
For[i = 1, i < 5, i++, Print[i]; Print[2 i]]
will print 10 lines.
Also, while it is clearly possible to use For and code in
Mathematica in a similar fashion to what would be done in C or
C++, this almost always leads to much poorer performance. My
experience with Mathematica indicates For in Mathematica is very
much like goto in C. It is there and can be used, but good code
that runs efficiently avoids this usage.