Working through chapter 7 and I have a question about a syntax discrepancy between the book's version and Core Logic:
The book implies that the following implementations of half-addero
are the same, but they're producing different values for me
;; frame 12
(defn half-addero
[x y r c]
(bit-xoro x y r)
(bit-ando x y c))
(run* [r]
(half-addero 1 1 r 1)) ;; -> (_0)
(defn half-addero-prime
[x y r c]
(conde
[(== 0 x) (== 0 y) (== 0 r) (== 0 c)]
[(== 1 x) (== 0 y) (== 1 r) (== 0 c)]
[(== 0 x) (== 1 y) (== 1 r) (== 0 c)]
[(== 1 x) (== 1 y) (== 0 r) (== 1 c)]))
(run* [r]
(half-addero-prime 1 1 r 1)) ;; -> (0)
Is there something obvious I'm doing wrong? I assume there's something incorrect about how I'm writing the two clauses for the half-addero
implementation but I can't tell what it is
Nevermind, I may have just figured it out. This seems to work correctly:
;; frame 12
(defn half-addero
[x y r c]
(all
(bit-xoro x y r)
(bit-ando x y c)))