mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
33 lines
904 B
Plaintext
33 lines
904 B
Plaintext
(defmodule Double
|
|
(def π 3.1415926536)
|
|
(register = (Fn [Double Double] Bool))
|
|
(register < (Fn [Double Double] Bool))
|
|
(register > (Fn [Double Double] Bool))
|
|
(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 sin (Fn [Double] Double))
|
|
(register cos (Fn [Double] Double))
|
|
(register acos (Fn [Double] Double))
|
|
(register atan2 (Fn [Double Double] Double))
|
|
(register sqrt (Fn [Double] Double))
|
|
(register str (Fn [Double] String))
|
|
(register copy (Fn [(Ref Double)] Double))
|
|
|
|
(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)))
|
|
|
|
)
|