Multiple expressions in for loops

From CodeCodex

Revision as of 14:44, 20 February 2011 by 79.91.219.32 (Talk)

Implementations

Java

You do it "à la C".

public class MultipleFor{
  public static void main (String [] args){
    for (int i=0, j=0; i < 10; i++, j--)
      System.out.println ("i = " + i + " j= " + j);
    }
}

Tcl

for {set i 0;set j 0} {$i < 10} {incr i;incr j -1} {puts "i = $i j = $j"}