Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: min and mindex

by jwkrahn (Monsignor)
on Nov 07, 2012 at 05:11 UTC ( #1002626=note: print w/replies, xml ) Need Help??


in reply to min and mindex

I'm try to get the min value and position in array1.

You could use a simple loop:

$ perl -le' my @array1 = (1,2,3,4,5,6,7); my @array2 = ("a","b","c","d","e","f","g"); my ( $min, $min_index ) = ( $array1[ 0 ], 0 ); for my $index ( 1 .. $#array1 ) { if ( $array1[ $index ] < $min ) { ( $min, $min_index ) = ( $array1[ $index ], $index ); } } print $min; print $min_index; ' 1 0

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002626]
help
Chatterbox?
[LanX]: List_of_earthquake s_in_Germany lower rhine rift valley
[LanX]: they need to be stronger to be felt in frankfurt ;-)
Discipulus boring meeting.. see you

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-01-18 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (161 votes). Check out past polls.