in reply to Re: Re: extracting corresponding values from another array
in thread extracting corresponding values from another array
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: extracting corresponding values from another array
by demerphq (Chancellor) on Dec 04, 2002 at 12:36 UTC | |
|
Re: Re: extracting corresponding values from another array
by Anonymous Monk on Dec 03, 2002 at 16:50 UTC | |
by Abigail-II (Bishop) on Dec 03, 2002 at 17:05 UTC |