in reply to Re^2: Finding the Shortest Element in an Array
in thread Finding the Shortest Element in an Array
Perhaps sort was chosen because using sort is easy on the person writing the code. That was the first thing that came to my mind -- just sort the list based on length, but i see no reason to use a Schwartzian Transform here. This should suffice, and while it may take longer and use more memory, it sure looks neat:
Code like that reminds me of my days painting dorm rooms. My boss would tell me "Let the brush do the work, not you." And yes, that would include using List::Util, FWIW.@array = sort { length($a) <=> length($b) } @array;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Finding the Shortest Element in an Array
by sauoq (Abbot) on Oct 13, 2005 at 22:18 UTC | |
by Perl Mouse (Chaplain) on Oct 14, 2005 at 11:05 UTC | |
by sauoq (Abbot) on Oct 14, 2005 at 15:30 UTC |