Skip to content

Commit

Permalink
Move all Real versions of .abs to Real.abs, remove "multi" from all .…
Browse files Browse the repository at this point in the history
…abs definitions.
  • Loading branch information
colomon committed Mar 31, 2010
1 parent a0fe385 commit 872898d
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/core/Any-num.pm
@@ -1,5 +1,5 @@
augment class Any {
multi method abs() {
method abs() {
pir::abs__Nn(self.Num);
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Complex.pm
Expand Up @@ -13,7 +13,7 @@ class Complex does Numeric {
($topic.Num ~~ $.re) && ($.im == 0);
}

multi method abs() {
method abs() {
($!re * $!re + $!im * $!im).sqrt
}

Expand Down
4 changes: 0 additions & 4 deletions src/core/Int.pm
Expand Up @@ -14,10 +14,6 @@ our sub upgrade_to_num_if_needed($test) {
}

augment class Int does Real {
multi method abs() {
self < 0 ?? -self !! self;
}

multi method ACCEPTS(Int $other) {
self == $other;
}
Expand Down
4 changes: 0 additions & 4 deletions src/core/Num.pm
Expand Up @@ -62,10 +62,6 @@ augment class Num does Real {
($signum * $b) / $d;
}
multi method abs() {
pir::abs__Nn(self);
}

multi method exp() {
pir::exp__Nn(self);
}
Expand Down
4 changes: 0 additions & 4 deletions src/core/Rat.pm
Expand Up @@ -57,10 +57,6 @@ class Rat does Real {
Rat.new($!numerator - $!denominator, $!denominator);
}

multi method abs() {
self < 0 ?? -self !! self;
}

our Int multi method sign {
# self ~~ NaN ?? NaN !! self <=> 0;
self < 0 ?? -1 !! ( self == 0 ?? 0 !! 1);
Expand Down
4 changes: 3 additions & 1 deletion src/core/Real.pm
@@ -1,3 +1,5 @@
role Real does Numeric {
# no methods yet
method abs() {
self < 0 ?? -self !! self;
}
}

0 comments on commit 872898d

Please sign in to comment.