Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix syntax errors
  • Loading branch information
moritz committed May 6, 2012
1 parent e447209 commit 05d4466
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions shootout/n-body.p6.pl
Expand Up @@ -8,7 +8,7 @@
constant SOLAR_MASS = (4 * PI * PI);
constant DAYS_PER_YEAR = 365.24;

constant LAST = 4;
constant $LAST = 4;

# @ns = ( sun, jupiter, saturn, uranus, neptune )
my Num @XS = (0, 4.84143144246472090e+00, 8.34336671824457987e+00, 1.28943695621391310e+01, 1.53796971148509165e+01);
Expand Down Expand Up @@ -38,8 +38,8 @@
sub advance($dt) {
my Num ($dx, $dy, $dz, $distance, $mag);

for 0..LAST -> $i {
for ($i+1)..LAST -> $k {
for 0..$LAST -> $i {
for ($i+1)..$LAST -> $k {
$dx = @XS[$i] - @XS[$k];
$dy = @YS[$i] - @YS[$k];
$dz = @ZS[$i] - @ZS[$k];
Expand All @@ -64,10 +64,10 @@ sub energy {
my Num ($e, $dx, $dy, $dz, $distance);

$e = 0.0;
for 0..LAST -> $i {
for 0..$LAST -> $i {
$e += 0.5 * @MASS[$i] *
(@VXS[$i]*@VXS[$i] + @VYS[$i]*@VYS[$i] + @VZS[$i]*@VZS[$i]);
for ($i + 1)..LAST -> $k {
for ($i + 1)..$LAST -> $k {
$dx = @XS[$i] - @XS[$k];
$dy = @YS[$i] - @YS[$k];
$dz = @ZS[$i] - @ZS[$k];
Expand All @@ -81,7 +81,7 @@ sub energy {
sub offset_momentum {
my Num ($px, $py, $pz) = (0.0, 0.0, 0.0);

for 0..LAST -> $i {
for 0..$LAST -> $i {
$px += @VXS[$i] * @MASS[$i];
$py += @VYS[$i] * @MASS[$i];
$pz += @VZS[$i] * @MASS[$i];
Expand Down

0 comments on commit 05d4466

Please sign in to comment.