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
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
Doloop, and are there other useful Mathematica constructs, aside from
Tuplesthat they should know about in order to avoid those loops?