Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 perusing the Monastery: (11)
As of 2014-09-19 18:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (144 votes), past polls