Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Why does my get_max_index function return zero? (High Water Mark Algorithm)

by Marshall (Canon)
on Jun 04, 2019 at 15:24 UTC ( [id://11100950]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub get_max_index {  #revisit how to define functions/"my" var ? (defa
    +ult parameters?)
        my $imax=0;
    ...
               $imax=$_[$i] if ($imax<=$_[$i]);}
        return $imax;
    }
    
  2. or download this
    use strict;
    use warnings;
    ...
    my @arr = (1..10);
    my $ans = get_max_index(@arr);
    print"$ans\n";
    
  3. or download this
    use strict;
    use warnings;
    ...
    my @arr = (1..10);
    my $ans = get_max_index(\@arr);  #pass reference to array!
    print"$ans\n";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found