Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: finding matches in the same array

by tlm (Prior)
on Apr 13, 2005 at 17:07 UTC ( [id://447510]=note: print w/replies, xml ) Need Help??


in reply to finding matches in the same array

How's this:

use List::Util 'sum'; my %collect; for my $i ( 0 .. $#@sequences ) { push @{ $collect{ $sequences[ $i ] } }, $numbers[ $i ]; } for my $sequence ( keys %collect ) { my $avg = ( sum @{$collect{$sequence}} )/@{$collect{$sequence}}; printf "sequence: $sequence = %.1f\n", $avg; }

the lowliest monk

Log In?
Username:
Password:

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

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

    No recent polls found