mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
65 lines
2.0 KiB
Plaintext
65 lines
2.0 KiB
Plaintext
(defmodule Double
|
|
(def pi 3.141592653589793)
|
|
(def e 2.718281828459045)
|
|
(register = (Fn [Double Double] Bool))
|
|
(register < (Fn [Double Double] Bool))
|
|
(register > (Fn [Double Double] Bool))
|
|
(register neg (Fn [Double] Double))
|
|
(register + (Fn [Double Double] Double))
|
|
(register - (Fn [Double Double] Double))
|
|
(register * (Fn [Double Double] Double))
|
|
(register / (Fn [Double Double] Double))
|
|
(register to-int (Fn [Double] Int))
|
|
(register from-int (Fn [Int] Double))
|
|
(register to-float (Fn [Double] Float))
|
|
(register from-float (Fn [Float] Double))
|
|
(register random (Fn [] Double))
|
|
(register random-between (Fn [Double Double] Double))
|
|
(register sin (Fn [Double] Double))
|
|
(register cos (Fn [Double] Double))
|
|
(register tan (Fn [Double] Double))
|
|
(register acos (Fn [Double] Double))
|
|
(register asin (Fn [Double] Double))
|
|
(register atan (Fn [Double] Double))
|
|
(register atan2 (Fn [Double Double] Double))
|
|
(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))
|
|
(register sqrt (Fn [Double] Double))
|
|
(register str (Fn [Double] String))
|
|
(register floor (Fn [Double] Double))
|
|
(register ceil (Fn [Double] Double))
|
|
(register mod (Fn [Double Double] Double))
|
|
(register copy (Fn [(Ref Double)] Double))
|
|
(register abs (Fn [Double] Double))
|
|
(register format (Fn [&String Double] String))
|
|
|
|
(defn clamp [min, max, val]
|
|
(if (> val max)
|
|
max
|
|
(if (< val min)
|
|
min
|
|
val)))
|
|
|
|
(defn approx [x y]
|
|
(if (> x y)
|
|
(< (- x y) 0.00001)
|
|
(< (- y x) 0.00001)))
|
|
|
|
(defn /= [x y]
|
|
(not (Double.= x y)))
|
|
|
|
(defn zero []
|
|
0.0)
|
|
|
|
(defn add-ref [x y]
|
|
(+ @x @y))
|
|
)
|