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

Re: min and mindex

by Khen1950fx (Canon)
on Nov 06, 2012 at 19:13 UTC ( #1002565=note: print w/replies, xml ) Need Help??


in reply to min and mindex

Maybe this can be of some help:
#!usr/bin/perl -l BEGIN { $| = 1; $^W = 1; } use strict; use warnings; use Statistics::Descriptive; use List::Util qw(minstr maxstr); my(@array1) = qw(1 2 3 4 5 6 7); my $min_index = Statistics::Descriptive::Sparse->new(); $min_index->add_data(@array1); my $min = $min_index->min; my $max = $min_index->max; my $mindex = $min_index->mindex; print "Min: ", $min, minstr 'a'..'g'; print "Max: ", $max, maxstr 'a'..'g'; print "Mindex: ", $mindex; print "Mindex: ", $min_index->mindex('a'..'g');

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002565]
help
Chatterbox?
[Eily]: I just wrote a oneliner to solve a (non perl) colleague's problem, and it worked on the first try
[Eily]: and he wasn't impressed
1nickt adds gingersnaps to the platter on the sideboard.
[Eily]: sure it was a pretty standard one liner (of the $h{$1} = $2 if /regex/; END { pp \%h; } variety), but he's not supposed to know that!
[Eily]: what's the point of writing perl if people aren't impressed :P

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2017-04-26 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (482 votes). Check out past polls.