in reply to Re^2: Map Vs Foreach
in thread Map Vs Foreach
I think we both agree that a "void map{}" is bad style. I looked at the post from Ratazong and saw the following code being bench marked:
This is a perfect thing for map{}: translate one thing to another. map{} can also make 1 to many and many to one translations. In general, I use map{} when the transformation can be expressed as a "one liner+" and foreach() when the code is longer. As a matter of style, this allows me to put foreach(@input) at the top instead of at the end of the program text, compare with: @output = map{lots of lines}@input.my @sqrt_results = map { sqrt ($_ ) } @input;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Map Vs Foreach
by JavaFan (Canon) on Nov 26, 2009 at 11:58 UTC | |
by JavaFan (Canon) on Nov 27, 2009 at 12:34 UTC | |
by Jenda (Abbot) on Dec 01, 2009 at 17:06 UTC | |
|
Re^4: Map Vs Foreach
by chromatic (Archbishop) on Nov 26, 2009 at 18:10 UTC |