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: [mg89388] Re: Instructions in for
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 8 Jun 2008 02:31:08 -0400 (EDT)
  • References: <g2dboa$9pm$1@smc.vnet.net>

Hi,

the "one instruction" can be CompoundExpression[]
usual written as infix notation with a ";"
and in

With[{n = 4},
  For[i = 0, i < n, i++,
   Print["I am"];
   Print["a CompoundExpression[]"];
   Print["and so this"];
   Print["one expression."];
   Print[i^2]
   ]
  ]

and

Hold[With[{n = 4},
    For[i = 0, i < n, i++,
     Print["I am"];
     Print["a CompoundExpression[]"];
     Print["and so this"];
     Print["one expression."];
     Print[i^2]
     ]
    ]] // FullForm

show this.

Regards
   Jens


Alejandra Lozada 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.
> 
> 


  • Prev by Date: Re: Instructions in for
  • Next by Date: Re: Notations and Symbols
  • Previous by thread: Re: Instructions in for
  • Next by thread: Re: Instructions in for