Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by karlgoethebier (Abbot)
on Jun 04, 2019 at 12:20 UTC ( [id://11100945]=note: print w/replies, xml ) Need Help??


in reply to Why does my get_max_index function return zero? (High Water Mark Algorithm)

Everything you need is already there:

#!/usr/bin/env perl use strict; use warnings; use feature qw(say); use List::Util qw(max shuffle); use List::MoreUtils qw(onlyidx); use Data::Dump; my @array = shuffle (1..10); dd \@array; my $max = max @array; say $max; say onlyidx {$_== $max} @array; __END__ Karls-Mac-mini:Desktop karl$ ./watermark.pl [7, 10, 9, 8, 2, 6, 4, 3, 5, 1] 10 1

I just cannibalized some fragments i found on my desktop in a hurry. But as far as i remember List::Util and List::MoreUtils come with implementations in pure Perl which might be good for further studies.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

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

    No recent polls found