[Bioperl-l] Adding all elements from an array of scores
Marco Blanchette
mblanche at berkeley.edu
Sat Aug 19 17:50:24 UTC 2006
Fairly simple Francois,
@scores = qw( 10 34 25 46 );
$y=0;
for $x (@scores){
$y = $y+$x;
}
print "$y\n";
Marco
On 8/19/06 9:49, "francois fauteux" <ffauteux at gmail.com> wrote:
> Hi;
>
> Having an array of alignment scores:
>
> @scores = ('x1', 'x2', 'x3', 'xn')
>
> Where x1, x2...xn are the score values and n is the number of elements
> in the array;
>
> How could I add the values x1 + x2 + x3 + ...xn (would have to adapt
> to arrays of variable number of elements);
>
> It would look like 'add $score[1] + $score[2] ... and so on until
> there is no more elements in the array';
>
> Thanks for hints;
>
> François Fauteux
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
______________________________
Marco Blanchette, Ph.D.
mblanche at uclink.berkeley.edu
Donald C. Rio's lab
Department of Molecular and Cell Biology
16 Barker Hall
University of California
Berkeley, CA 94720-3204
Tel: (510) 642-1084
Cell: (510) 847-0996
Fax: (510) 642-6062
--
More information about the Bioperl-l
mailing list