in reply to finding matches in the same array
At this point, each entry in the hash has a "sequence" for key and a reference to an array containing the "numbers" for that sequence as value - computing the average should be pretty easy, e.g.:my %occurrences; push @{$occurrences{$sequence[$_]}}, $numbers[$_] foreach (0 .. $#sequence);
I leave the union of the two snippets as an exercise, just in case it's an homework :)my $sum; $sum += $_ foreach (@{$occurrences{'atcg'}}); my $average = $sum / scalar(@{$occurrences{'atcg'}});
Update: fixed a typo in first snipped, thanks to Postular Postulant.
Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")
Don't fool yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: finding matches in the same array
by bageler (Hermit) on Apr 13, 2005 at 18:07 UTC | |
by polettix (Vicar) on Apr 13, 2005 at 18:19 UTC |