in reply to Re: When would you choose foreach instead of map?
in thread When would you choose foreach instead of map?
Is it possible to generate the result 'X' in such a way that I can automatically deduce the method that was used to generate that result (without looking at the source code) by evaluating one or more quantifiable measures of fitness?
Where 'X' is the sum of the numbers 1 .. 1_000_000.
p:\test>x1 500000500000 p:\test>x2 500000500000
The programs (in no particular order).
andmap{ $sum += $_ } 1 .. 1000000; print $sum;
$sum += $_ for 1 .. 1000000; print $sum;
External metric: One of them uses 3MB, the other 96MB :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: When would you choose foreach instead of map?
by eric256 (Parson) on May 21, 2004 at 04:17 UTC | |
by Abigail-II (Bishop) on May 21, 2004 at 11:19 UTC | |
by eric256 (Parson) on May 21, 2004 at 15:02 UTC | |
|
Re^3: When would you choose foreach instead of map?
by Anonymous Monk on May 21, 2004 at 05:39 UTC | |
by BrowserUk (Patriarch) on May 21, 2004 at 10:28 UTC | |
|
Re: Re: Re: When would you choose foreach instead of map?
by dimar (Curate) on May 21, 2004 at 16:49 UTC | |
by BrowserUk (Patriarch) on May 21, 2004 at 16:59 UTC |