Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Welcome to the Monastery
 
PerlMonks  

Re: Returning indices with same values for array within hash.

by johngg (Abbot)
on Nov 10, 2013 at 15:48 UTC ( #1061909=note: print w/ replies, xml ) Need Help??


in reply to Returning indices with same values for array within hash.

Not answering your query, but running min every time through the grep is likely to be wasteful if you are dealing with large arrays. It might be better to find the minimum once first.

$ perl -Mstrict -Mwarnings -MList::Util=min -E ' my @NI = ( 1, 1, 3, 4 ); my @NI_index = do { my $min = min @NI; grep { $NI[ $_ ] == $min } 0 .. $#NI; }; say qq{@NI_index};' 0 1 $

I hope this is of interest.

Cheers,

JohnGG


Comment on Re: Returning indices with same values for array within hash.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-04-20 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls