Re: Instructions in for
- To: mathgroup at smc.vnet.net
- Subject: [mg89404] Re: Instructions in for
- From: magma <maderri2 at gmail.com>
- Date: Sun, 8 Jun 2008 02:34:15 -0400 (EDT)
- References: <g2dboa$9pm$1@smc.vnet.net>
On Jun 7, 9:01 am, "Alejandra Lozada" <alo... at gmail.com> wrote:
> Hello Group,
>
> ______________________________________________
> 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?
>
> Thank you All,
> Alejandra L.
It works more or less like in C++.
You write several commands separated by semicolons.
For[i = 0, i < 4, i++,
Print[i];
Print[i^2];
Print[i^3];
]
the semicolon is in reality the CompoundExpression command.
Type it in Mathematica and then press F1 to get an explanation
saludos