mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-26 05:45:37 +03:00
core: added numerical ref modules
This commit is contained in:
parent
f93eb16615
commit
eba07aeb34
@ -61,7 +61,15 @@
|
||||
|
||||
(defn add-ref [x y]
|
||||
(+ @x @y))
|
||||
|
||||
(defn cmp [x y]
|
||||
(if (= (the Double @x) @y) 0 (if (< @x @y) -1 1)))
|
||||
)
|
||||
|
||||
(defmodule DoubleRef
|
||||
(defn = [a b]
|
||||
(Double.= @a @b))
|
||||
|
||||
(defn < [a b]
|
||||
(Double.< @a @b))
|
||||
|
||||
(defn > [a b]
|
||||
(Double.> @a @b))
|
||||
)
|
||||
|
@ -61,7 +61,15 @@
|
||||
|
||||
(defn add-ref [x y]
|
||||
(+ @x @y))
|
||||
|
||||
(defn cmp [x y]
|
||||
(if (= (the Float @x) @y) 0 (if (< @x @y) -1 1)))
|
||||
)
|
||||
|
||||
(defmodule FloatRef
|
||||
(defn = [a b]
|
||||
(Float.= @a @b))
|
||||
|
||||
(defn < [a b]
|
||||
(Float.< @a @b))
|
||||
|
||||
(defn > [a b]
|
||||
(Float.> @a @b))
|
||||
)
|
||||
|
@ -41,7 +41,15 @@
|
||||
|
||||
(defn add-ref [x y]
|
||||
(+ @x @y))
|
||||
|
||||
(defn cmp [x y]
|
||||
(if (= (the Int @x) @y) 0 (if (< @x @y) -1 1)))
|
||||
)
|
||||
|
||||
(defmodule IntRef
|
||||
(defn = [a b]
|
||||
(Int.= @a @b))
|
||||
|
||||
(defn < [a b]
|
||||
(Int.< @a @b))
|
||||
|
||||
(defn > [a b]
|
||||
(Int.> @a @b))
|
||||
)
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
(definterface random (Fn [] a))
|
||||
(definterface random-between (Fn [a a] a))
|
||||
(definterface cmp (Fn [&a &a] Int))
|
||||
|
||||
(definterface pi a)
|
||||
|
||||
@ -41,3 +40,8 @@
|
||||
(defn >= [a b]
|
||||
(or (> a b)
|
||||
(= a b)))
|
||||
|
||||
(defn cmp [a b]
|
||||
(if (= a b)
|
||||
0
|
||||
(if (< a b) -1 1)))
|
||||
|
@ -39,7 +39,15 @@
|
||||
|
||||
(defn even? [a] (= (mod a 2l) 0l))
|
||||
(defn odd? [a] (not (even? a)))
|
||||
|
||||
(defn cmp [x y]
|
||||
(if (= (the Long @x) @y) 0 (if (< @x @y) -1 1)))
|
||||
)
|
||||
|
||||
(defmodule LongRef
|
||||
(defn = [a b]
|
||||
(Long.= @a @b))
|
||||
|
||||
(defn < [a b]
|
||||
(Long.< @a @b))
|
||||
|
||||
(defn > [a b]
|
||||
(Long.> @a @b))
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user