Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start to implement sign.
  • Loading branch information
colomon committed Jul 26, 2011
1 parent d0ce251 commit 10d4051
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/Numeric.pm
Expand Up @@ -35,6 +35,10 @@ multi prefix:<->(\$a) { -$a.Numeric }
proto prefix:<abs>(|$) { * }
multi prefix:<abs>(\$a) { abs $a.Numeric }

proto sub sign(|$) {*}
multi sub sign(Numeric \$x) { $x.sign }
multi sub sign(Cool \$x) { $x.Numeric.sign }

proto sub log(|$) {*}
multi sub log(Numeric $x) { $x.log }
multi sub log(Numeric $x, Numeric $base) { $x.log($base) }
Expand Down
1 change: 1 addition & 0 deletions src/core/Real.pm
Expand Up @@ -3,6 +3,7 @@ class Complex { ... }
# XxX role Real does Numeric { ... }
my class Real {
method abs() { self < 0 ?? -self !! self }
method sign() { self < 0 ?? -1 !! self == 0 ?? 0 !! 1 }
method sqrt() { self.Bridge.sqrt }
method sin() { self.Bridge.sin }
method cos() { self.Bridge.cos }
Expand Down

0 comments on commit 10d4051

Please sign in to comment.