public class Loop { public static void main (String [] argv) { for (int i = 0; i < 10; i ++) { System . out . println (i); } } }
And here it is in AWK:
BEGIN {for (i = 0; i < 10; i ++) {print i}}
And here it is in LPC:
void loop () { int i; for (i = 0; i < 10; i ++) { write (i + "\n"); } }
It's not just C.
Feel free to find for my $i (map {$_ * 2} 0 .. 1000000 / 2) {$sum += $i} a bit strange, because it comes closer to the quoted while statement. But then, don't say that when we change the $i += 2 to $i ++ the alternative is a foreach. That would also be closer to the while.
I know the foreach is more efficient than the for, but only in the case of incrementing the variant by 1. The for() is far more flexible than the foreach(). The for() is a less error-prone, and easier way of writing the while.
Abigail
In reply to Re: extracting corresponding values from another array
by Abigail-II
in thread extracting corresponding values from another array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |