in reply to How to get the index of smallest whole number in an array?
#!/usr/bin/perl -l # https://perlmonks.org/?node_id=1217669 use strict; use warnings; my @array = ('3','4','71','1', '-598', '-100203'); my ($answer) = map $_->[0], sort { $a->[1] <=> $b->[1] } grep $_->[1] >= 0, map [ $_, $array[$_] ], 0 .. $#array; print $answer;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get the index of smallest whole number in an array?
by AnomalousMonk (Archbishop) on Jul 01, 2018 at 02:00 UTC | |
|
Re^2: How to get the index of smallest whole number in an array?
by johngg (Canon) on Jul 01, 2018 at 11:06 UTC | |
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 |