1

Help me please, how I can write two action in the body of the cycle "for"?

For example, if I need to write Print[] and Append[] at each iteration.

GThompson
  • 105
  • 5

1 Answers1

1

You can use CompoundExpression (;) (expressions separated by ;) in any argument of For:

For[i = 0; a = {}, i < 4, i++, Print[i]; AppendTo[a, i]]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896