aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-09-22 18:40:30 +0100
committerGitHub <noreply@github.com>2019-09-22 18:40:30 +0100
commitb19102e9150be1f336d8f137149aae6fe599ca6d (patch)
treebbb68aa406c73a01551a899fa43f255b96482880
parentcaeeb856feb39524c9ddbd375bfb512138f32d17 (diff)
parent8413ab2cbfb5548998dd5f674c3893abbe6b8def (diff)
downloadperlweeklychallenge-club-b19102e9150be1f336d8f137149aae6fe599ca6d.tar.gz
perlweeklychallenge-club-b19102e9150be1f336d8f137149aae6fe599ca6d.tar.bz2
perlweeklychallenge-club-b19102e9150be1f336d8f137149aae6fe599ca6d.zip
Merge pull request #654 from kolcon/master
process array only once
-rw-r--r--challenge-026/lubos-kolouch/perl5/ch-2.pl7
1 files changed, 5 insertions, 2 deletions
diff --git a/challenge-026/lubos-kolouch/perl5/ch-2.pl b/challenge-026/lubos-kolouch/perl5/ch-2.pl
index 96b5be4b04..2575514bae 100644
--- a/challenge-026/lubos-kolouch/perl5/ch-2.pl
+++ b/challenge-026/lubos-kolouch/perl5/ch-2.pl
@@ -30,8 +30,11 @@ sub get_mean {
my ( $sin_sum, $cos_sum );
- $sin_sum += sin( deg2rad($_) ) for @angles;
- $cos_sum += cos( deg2rad($_) ) for @angles;
+ for (@angles) {
+ $sin_sum += sin( deg2rad($_) );
+ $cos_sum += cos( deg2rad($_) );
+ }
+
return rad2deg( atan2( $sin_sum, $cos_sum ) );
}