Possible Duplicate:
Iterating over lists in Mathematica
While there are some cases where a For loop might be reasonable, it's a general mantra – one I subscribe to myself – that "if you are using a For loop in Mathematica, you are probably doing it wrong". But For and Do loops are familiar to people who already know other programming languages. It is common for new Mathematica users to rely on loop constructs, only to become frustrated with performance or code complexity.
My question is: are there some general rules of thumb that would help new users select the appropriate alternative to a procedural
FororDoloop, and are there other useful Mathematica constructs, aside fromRandomVariate/Nest/Fold/Inner/Outer/Tuplesthat they should know about in order to avoid those loops?