in reply to Re: How to get the index of smallest whole number in an array?
in thread How to get the index of smallest whole number in an array?
The extra maps could be dispensed with I think.
johngg@abouriou ~/perl/Monks $ perl -Mstrict -Mwarnings -E ' my @arr = ( 3, 4, 71, 1, -598, -100203 ); say for ( sort { $arr[ $a ] <=> $arr[ $b ] } grep { $arr[ $_ ] >= 0 } 0 .. $#arr )[ 0 ];' 3
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to get the index of smallest whole number in an array?
by corenth (Monk) on Jul 02, 2018 at 18:07 UTC | |
by AnomalousMonk (Archbishop) on Jul 02, 2018 at 19:52 UTC | |
by BrowserUk (Patriarch) on Jul 02, 2018 at 19:07 UTC | |
by corenth (Monk) on Jul 02, 2018 at 20:35 UTC |