Skip to content

Commit

Permalink
Implement (generic) Numeric.succ and Numeric.pred. Remove the multi f…
Browse files Browse the repository at this point in the history
…rom Rat's .succ and .pred.
  • Loading branch information
colomon committed May 18, 2010
1 parent 1bf6eab commit 980e03c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/core/Numeric.pm
Expand Up @@ -3,6 +3,14 @@ role Numeric {
self;
}

method succ(Numeric $x:) {
$x + 1;
}

method pred(Numeric $x:) {
$x - 1;
}

method abs(Numeric $x:) {
note "$.WHAT() needs a version of .abs";
fail "$.WHAT() needs a version of .abs";
Expand Down
5 changes: 3 additions & 2 deletions src/core/Rat.pm
Expand Up @@ -54,10 +54,11 @@ class Rat is Cool does Real {

multi method nude() { $.numerator, $.denominator; }

multi method succ {
method succ {
Rat.new($!numerator + $!denominator, $!denominator);
}
multi method pred {

method pred {
Rat.new($!numerator - $!denominator, $!denominator);
}
}
Expand Down

0 comments on commit 980e03c

Please sign in to comment.