(import /src/calc)
(defmacro defop
[name arity f]
~(def ,name (:new calc/Operation
:arity ,arity
:type ,(keyword name)
:fun-ref ,f)))
(defop add 2 +)
(defop sub 2 -)
(defop div 2 /)
(defop mul 2 *)
(defop sqrt 1 math/sqrt)
(defop lt 2 (fn [x y] (if (< x y) 1 0)))
(defop gt 2 (fn [x y] (if (> x y) 1 0)))
(defop lte 2 (fn [x y] (if (<= x y) 1 0)))
(defop gte 2 (fn [x y] (if (>= x y) 1 0)))
(defop eq 2 (fn [x y] (if (= x y) 1 0)))
(defop cmp 2 cmp)