Monthly Archives: June 2009

for loop Fun

Actionscript:
  1. var leng:int = 10;
  2. for (var i:int = 0, j:int = leng;  i <leng; i++, j = leng - i){
  3.     trace(i, j);
  4. }
  5.  
  6. /*outputs
  7. 0 10
  8. 1 9
  9. 2 8
  10. 3 7
  11. 4 6
  12. 5 5
  13. 6 4
  14. 7 3
  15. 8 2
  16. 9 1
  17. */

Looping backwards and forwards.

Posted in Math, misc, one-liners | Tagged , | Leave a comment