core: added numerical ref modules

This commit is contained in:
hellerve 2018-01-15 16:27:05 +01:00
parent f93eb16615
commit eba07aeb34
5 changed files with 49 additions and 13 deletions

View File

@ -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))
)

View File

@ -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))
)

View File

@ -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))
)

View File

@ -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)))

View File

@ -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))
)