-
Notifications
You must be signed in to change notification settings - Fork 124
/
arithmetic.clj
45 lines (40 loc) · 1.17 KB
/
arithmetic.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(ns clojure.core.logic.arithmetic
(:refer-clojure :exclude [reify == inc = > < >= <=])
(:use clojure.core.logic))
(defmacro = [x y]
"Goal for testing whether x and y are equal. Non-relational."
`(fn [a#]
(let [wx# (walk a# ~x)
wy# (walk a# ~y)]
(if (clojure.core/= wx# wy# )
a# nil))))
(defmacro > [x y]
"Goal for testing whether x is greater than y. Non-relational."
`(fn [a#]
(let [wx# (walk a# ~x)
wy# (walk a# ~y)]
(if (clojure.core/> wx# wy# )
a# nil))))
(defmacro >= [x y]
"Goal for testing whether x is greater than or equal to y.
Non-relational."
`(fn [a#]
(let [wx# (walk a# ~x)
wy# (walk a# ~y)]
(if (clojure.core/>= wx# wy# )
a# nil))))
(defmacro < [x y]
"Goal for testing whether x is less than y. Non-relational."
`(fn [a#]
(let [wx# (walk a# ~x)
wy# (walk a# ~y)]
(if (clojure.core/< wx# wy# )
a# nil))))
(defmacro <= [x y]
"Goal for testing whether x is less than or equal to y.
Non-relational."
`(fn [a#]
(let [wx# (walk a# ~x)
wy# (walk a# ~y)]
(if (clojure.core/<= wx# wy#)
a# nil))))