Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:sorear/niecza into serialize
  • Loading branch information
sorear committed Oct 27, 2011
2 parents 9ceaa8e + 71325b0 commit 2a9f24b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/CORE.setting
Expand Up @@ -311,6 +311,7 @@ my class Cool {
method ln() { Q:CgOp { (ln {self}) } }
multi method log() { self.ln }
multi method log($base) { self.ln / $base.ln }
method log10() { self.ln / 10.ln }
method sin() { Q:CgOp { (sin {self}) } }
method asin() { Q:CgOp { (asin {self}) } }
method cos() { Q:CgOp { (cos {self}) } }
Expand All @@ -336,6 +337,8 @@ my class Cool {
method cotanh() { Q:CgOp { (cotanh {self}) } }
method acotanh() { Q:CgOp { (acotanh {self}) } }
method atan2($x = 1) { Q:CgOp { (atan2 {self} {$x}) } }
method unpolar($angle) { unpolar(self, $angle); }
method cis() { cis(self); }
method rand() { self * rand; }
method split($matcher, $limit?, :$all?) {
Expand Down Expand Up @@ -605,6 +608,7 @@ my class Complex is Numeric {
method re() { Q:CgOp { (complex_re {self}) } }
method im() { Q:CgOp { (complex_im {self}) } }
method conjugate() { self.re - (self.im)i }
method polar() { self.abs, atan2(self.im, self.re); }
}
my class FatRat is Real {
method new($n,$d) { FatRat.succ * $n / $d }
Expand Down Expand Up @@ -1933,7 +1937,8 @@ sub round($x, $scale=1) { floor($x / $scale + 0.5) * $scale }
sub truncate($x) { $x.Int }
sub sign($x) { $x < 0 ?? -1 !! $x > 0 ?? 1 !! 0 }
sub sqrt($x) { Q:CgOp { (sqrt {$x}) } }
sub exp($x) { $x.exp }
multi sub exp($x) { $x.exp }
multi sub exp($x, $base) { $base ** $x }
# XXX 'Order' type
sub infix:« <=> » is equiv<leg> ($a, $b) { $a < $b ?? -1 !! $a > $b ?? 1 !! 0 }
# XXX polymorphic equality
Expand Down Expand Up @@ -2144,6 +2149,13 @@ sub lines($filehandle = $*IN) { $filehandle.lines }
sub prompt($msg) { print $msg; $*IN.get }
sub getc($handle) { $handle.getc }
multi sub log($x) { $x.log }
multi sub log($x, $base) { $x.log($base) }
sub log10($x) { $x.log(10) }
sub unpolar($mag, $angle) { Complex.new($mag * $angle.cos, $mag * $angle.sin); }
sub cis($angle) { Complex.new($angle.cos, $angle.sin); }
sub sin($x) { $x.sin }
sub asin($x) { $x.asin }
sub cos($x) { $x.cos }
Expand Down
6 changes: 6 additions & 0 deletions t/spectest.data
Expand Up @@ -292,11 +292,17 @@ S32-hash/slice.t
S32-list/first.t
S32-list/pick.t
S32-num/abs.t
S32-num/complex.t
S32-num/exp.t
S32-num/int.t
S32-num/log.t
S32-num/pi.t
S32-num/polar.t
S32-num/power.t
S32-num/rat.t
S32-num/sign.t
S32-num/sqrt.t
S32-num/unpolar.t
S32-str/append.t
S32-str/bool.t
S32-str/capitalize.t
Expand Down

0 comments on commit 2a9f24b

Please sign in to comment.