2017-06-26 12:15:03 +03:00
|
|
|
(defmodule Double
|
2017-12-15 00:48:19 +03:00
|
|
|
(def pi 3.141592653589793)
|
2017-11-22 20:25:03 +03:00
|
|
|
(def e 2.718281828459045)
|
2017-10-24 14:52:32 +03:00
|
|
|
(register = (Fn [Double Double] Bool))
|
2017-10-20 01:27:35 +03:00
|
|
|
(register < (Fn [Double Double] Bool))
|
|
|
|
(register > (Fn [Double Double] Bool))
|
2017-11-15 16:47:03 +03:00
|
|
|
(register neg (Fn [Double] Double))
|
2017-06-26 12:15:03 +03:00
|
|
|
(register + (Fn [Double Double] Double))
|
|
|
|
(register - (Fn [Double Double] Double))
|
|
|
|
(register * (Fn [Double Double] Double))
|
|
|
|
(register / (Fn [Double Double] Double))
|
2017-10-13 17:11:23 +03:00
|
|
|
(register to-int (Fn [Double] Int))
|
|
|
|
(register from-int (Fn [Int] Double))
|
2017-11-15 16:47:03 +03:00
|
|
|
(register to-float (Fn [Double] Float))
|
|
|
|
(register from-float (Fn [Float] Double))
|
2017-12-28 20:02:50 +03:00
|
|
|
(register random (Fn [] Double))
|
|
|
|
(register random-between (Fn [Double Double] Double))
|
2017-06-26 12:15:03 +03:00
|
|
|
(register sin (Fn [Double] Double))
|
|
|
|
(register cos (Fn [Double] Double))
|
2017-11-15 16:06:49 +03:00
|
|
|
(register tan (Fn [Double] Double))
|
2017-10-20 01:44:25 +03:00
|
|
|
(register acos (Fn [Double] Double))
|
2017-11-15 16:06:49 +03:00
|
|
|
(register asin (Fn [Double] Double))
|
|
|
|
(register atan (Fn [Double] Double))
|
2017-10-20 01:27:35 +03:00
|
|
|
(register atan2 (Fn [Double Double] Double))
|
2017-11-15 16:06:49 +03:00
|
|
|
(register cosh (Fn [Double] Double))
|
|
|
|
(register sinh (Fn [Double] Double))
|
|
|
|
(register tanh (Fn [Double] Double))
|
|
|
|
(register exp (Fn [Double] Double))
|
|
|
|
(register frexp (Fn [Double (Ref Int)] Double))
|
|
|
|
(register ldexp (Fn [Double Int] Double))
|
|
|
|
(register log (Fn [Double] Double))
|
|
|
|
(register log10 (Fn [Double] Double))
|
|
|
|
(register modf (Fn [Double (Ref Double)] Double))
|
|
|
|
(register pow (Fn [Double Double] Double))
|
2017-10-20 01:27:35 +03:00
|
|
|
(register sqrt (Fn [Double] Double))
|
2017-10-10 21:13:58 +03:00
|
|
|
(register str (Fn [Double] String))
|
2017-11-06 20:08:07 +03:00
|
|
|
(register floor (Fn [Double] Double))
|
2017-11-15 16:06:49 +03:00
|
|
|
(register ceil (Fn [Double] Double))
|
|
|
|
(register mod (Fn [Double Double] Double))
|
2017-10-19 19:34:44 +03:00
|
|
|
(register copy (Fn [(Ref Double)] Double))
|
2017-11-07 17:06:47 +03:00
|
|
|
(register abs (Fn [Double] Double))
|
2017-12-30 22:16:31 +03:00
|
|
|
(register format (Fn [&String Double] String))
|
2017-10-20 01:44:25 +03:00
|
|
|
|
|
|
|
(defn clamp [min, max, val]
|
|
|
|
(if (> val max)
|
|
|
|
max
|
|
|
|
(if (< val min)
|
|
|
|
min
|
|
|
|
val)))
|
2017-10-24 14:52:32 +03:00
|
|
|
|
|
|
|
(defn approx [x y]
|
|
|
|
(if (> x y)
|
|
|
|
(< (- x y) 0.00001)
|
|
|
|
(< (- y x) 0.00001)))
|
|
|
|
|
2017-11-14 20:07:35 +03:00
|
|
|
(defn /= [x y]
|
2017-11-27 14:36:17 +03:00
|
|
|
(not (Double.= x y)))
|
2017-12-04 09:21:35 +03:00
|
|
|
|
|
|
|
(defn zero []
|
|
|
|
0.0)
|
|
|
|
|
|
|
|
(defn add-ref [x y]
|
2018-01-28 07:56:03 +03:00
|
|
|
(Double.+ @x @y))
|
2018-01-15 18:27:05 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
(defmodule DoubleRef
|
|
|
|
(defn = [a b]
|
|
|
|
(Double.= @a @b))
|
|
|
|
|
|
|
|
(defn < [a b]
|
|
|
|
(Double.< @a @b))
|
2018-01-15 18:10:11 +03:00
|
|
|
|
2018-01-15 18:27:05 +03:00
|
|
|
(defn > [a b]
|
|
|
|
(Double.> @a @b))
|
2017-10-24 14:52:32 +03:00
|
|
|
)
|