New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional $base argument for log() #1382
Comments
From @KodiologistThis is a simplistic implementation of the optional $base argument to |
From @Kodiologistlog.diffdiff --git a/src/setting/Any-num.pm b/src/setting/Any-num.pm
index 193512c..787845f 100644
--- a/src/setting/Any-num.pm
+++ b/src/setting/Any-num.pm
@@ -79,6 +79,10 @@ class Any is also {
$.Num.log();
}
+ multi method log($base) {
+ $.Num.log($base);
+ }
+
our multi method !from-radians($base) {
given $base {
when /:i ^d/ { self * 180/pi } # Convert to degrees.
@@ -194,6 +198,7 @@ class Any is also {
multi sub abs($x) { (+$x).abs() }
multi sub exp($x) { $x.Num.exp() }
multi sub log($x) { $x.Num.log() }
+multi sub log($x, $base) { $x.Num.log($base) }
multi sub log10($x) { $x.Num.log10 }
# jnthn says that we should have both the multi sub declaration and the proto.
diff --git a/src/setting/Complex.pm b/src/setting/Complex.pm
index 791a816..70e93fa 100644
--- a/src/setting/Complex.pm
+++ b/src/setting/Complex.pm
@@ -147,6 +147,10 @@ class Complex {
}
}
+ multi method log($base) {
+ $.log / $base.log;
+ }
+
multi method log10() {
$.log / 10.log;
}
@@ -304,6 +308,10 @@ multi sub log(Complex $x) {
$x.log()
}
+multi sub log(Complex $x, $base) {
+ $x.log($base)
+}
+
multi sub log10(Complex $x) {
$x.log10;
}
diff --git a/src/setting/Num.pm b/src/setting/Num.pm
index e88d587..0360e86 100644
--- a/src/setting/Num.pm
+++ b/src/setting/Num.pm
@@ -238,6 +238,10 @@ class Num is also {
}
}
+ multi method log($base) {
+ $.log / $base.log
+ }
+
our method log10 {
Q:PIR {
$N0 = self
|
From @moritzI don't know if your patch ever got applied, but we do have a log() Thank you for your patch, |
@moritz - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#70105 (status was 'resolved')
Searchable as RT70105$
The text was updated successfully, but these errors were encountered: