diff options
Diffstat (limited to 'source/lux/math.lux')
-rw-r--r-- | source/lux/math.lux | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/source/lux/math.lux b/source/lux/math.lux deleted file mode 100644 index a60ce512c..000000000 --- a/source/lux/math.lux +++ /dev/null @@ -1,80 +0,0 @@ -## Copyright (c) Eduardo Julian. All rights reserved. -## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -## If a copy of the MPL was not distributed with this file, -## You can obtain one at http://mozilla.org/MPL/2.0/. - -(;import lux - (lux/data/number/int #open ("i:" Int/Number))) - -## [Constants] -(do-template [<name> <value>] - [(def #export <name> - Real - (_jvm_getstatic "java.lang.Math" <value>))] - - [e "E"] - [pi "PI"] - ) - -## [Functions] -(do-template [<name> <method>] - [(def #export (<name> n) - (-> Real Real) - (_jvm_invokestatic "java.lang.Math" <method> ["double"] [n]))] - - [cos "cos"] - [sin "sin"] - [tan "tan"] - - [acos "acos"] - [asin "asin"] - [atan "atan"] - - [cosh "cosh"] - [sinh "sinh"] - [tanh "tanh"] - - [ceil "ceil"] - [floor "floor"] - - [exp "exp"] - [log "log"] - - [cbrt "cbrt"] - [sqrt "sqrt"] - - [->degrees "toDegrees"] - [->radians "toRadians"] - ) - -(def #export (round n) - (-> Real Int) - (_jvm_invokestatic "java.lang.Math" "round" ["double"] [n])) - -(do-template [<name> <method>] - [(def #export (<name> x y) - (-> Real Real Real) - (_jvm_invokestatic "java.lang.Math" <method> ["double" "double"] [x y]))] - - [atan2 "atan2"] - [pow "pow"] - ) - -(def (gcd' a b) - (-> Int Int Int) - (case b - 0 a - _ (gcd' b (i:% a b)))) - -(def #export (gcd a b) - (-> Int Int Int) - (gcd' (i:abs a) (i:abs b))) - -(def #export (lcm x y) - (-> Int Int Int) - (case [x y] - (\or [_ 0] [0 _]) - 0 - - _ - (i:abs (i:* (i:/ x (gcd x y)) y)))) |