Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 scrutinizing the Monastery: (5)
As of 2015-07-06 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls