aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/math.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/math.lux')
-rw-r--r--stdlib/source/lux/math.lux62
1 files changed, 26 insertions, 36 deletions
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index e87bb1b1b..6f41b3e9b 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -5,7 +5,6 @@
[number "Int/" Number<Int>]
[product]
text/format)
- host
[compiler]
(macro ["s" syntax #+ syntax: Syntax "s/" Functor<Syntax>]
[ast])))
@@ -14,10 +13,10 @@
(do-template [<name> <value>]
[(def: #export <name>
Real
- (_lux_proc ["jvm" <value>] []))]
+ (_lux_proc ["math" <value>] []))]
- [e "getstatic:java.lang.Math:E"]
- [pi "getstatic:java.lang.Math:PI"]
+ [e "e"]
+ [pi "pi"]
)
(def: #export tau
@@ -26,52 +25,43 @@
6.28318530717958647692)
(do-template [<name> <method>]
- [(def: #export (<name> n)
+ [(def: #export (<name> input)
(-> Real Real)
- (_lux_proc ["jvm" <method>] [n]))]
+ (_lux_proc ["math" <method>] [input]))]
- [cos "invokestatic:java.lang.Math:cos:double"]
- [sin "invokestatic:java.lang.Math:sin:double"]
- [tan "invokestatic:java.lang.Math:tan:double"]
+ [cos "cos"]
+ [sin "sin"]
+ [tan "tan"]
- [acos "invokestatic:java.lang.Math:acos:double"]
- [asin "invokestatic:java.lang.Math:asin:double"]
- [atan "invokestatic:java.lang.Math:atan:double"]
+ [acos "acos"]
+ [asin "asin"]
+ [atan "atan"]
- [cosh "invokestatic:java.lang.Math:cosh:double"]
- [sinh "invokestatic:java.lang.Math:sinh:double"]
- [tanh "invokestatic:java.lang.Math:tanh:double"]
+ [cosh "cosh"]
+ [sinh "sinh"]
+ [tanh "tanh"]
- [exp "invokestatic:java.lang.Math:exp:double"]
- [log "invokestatic:java.lang.Math:log:double"]
+ [exp "exp"]
+ [log "log"]
- [root2 "invokestatic:java.lang.Math:sqrt:double"]
- [root3 "invokestatic:java.lang.Math:cbrt:double"]
+ [root2 "root2"]
+ [root3 "root3"]
- [degrees "invokestatic:java.lang.Math:toDegrees:double"]
- [radians "invokestatic:java.lang.Math:toRadians:double"]
- )
+ [degrees "degrees"]
+ [radians "radians"]
-(do-template [<name> <method>]
- [(def: #export (<name> n)
- (-> Real Real)
- (_lux_proc ["jvm" <method>] [n]))]
-
- [ceil "invokestatic:java.lang.Math:ceil:double"]
- [floor "invokestatic:java.lang.Math:floor:double"]
+ [ceil "ceil"]
+ [floor "floor"]
+ [round "round"]
)
-(def: #export (round n)
- (-> Real Real)
- (int-to-real (_lux_proc ["jvm" "invokestatic:java.lang.Math:round:double"] [n])))
-
(do-template [<name> <method>]
[(def: #export (<name> param subject)
(-> Real Real Real)
- (_lux_proc ["jvm" <method>] [subject param]))]
+ (_lux_proc ["math" <method>] [subject param]))]
- [atan2 "invokestatic:java.lang.Math:atan2:double,double"]
- [pow "invokestatic:java.lang.Math:pow:double,double"]
+ [atan2 "atan2"]
+ [pow "pow"]
)
(def: #export (log' base input)