Skip to content

Commit

Permalink
[src/core/Int.pm] made gcd signature slurpy
Browse files Browse the repository at this point in the history
This way, there's less need to invent a corresponding infix:<gcd> op
just to be able to reduce over it. And it's not like &gcd is spec'd
anyway. :-)
  • Loading branch information
Carl Masak committed May 3, 2011
1 parent 7114f56 commit 42dcfd1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/Int.pm
Expand Up @@ -102,4 +102,13 @@ our multi sub infix:<**>(Int $a, Int $b) {
}
}

proto sub gcd($x, $y) { $x.gcd($y); }
proto sub gcd(*@n) {
return Int unless @n;
my $gcd = shift @n;

for @n {
$gcd.=gcd($_);
}

return $gcd;
}

0 comments on commit 42dcfd1

Please sign in to comment.