core-logic

2019-03-10T15:34:09.002100Z

Working through chapter 7 and I have a question about a syntax discrepancy between the book's version and Core Logic:

2019-03-10T15:34:52.002700Z

The book implies that the following implementations of half-addero are the same, but they're producing different values for me

2019-03-10T15:35:10.003100Z

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

2019-03-10T15:35:55.004100Z

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

2019-03-10T15:37:22.004500Z

Nevermind, I may have just figured it out. This seems to work correctly:

2019-03-10T15:37:26.004700Z

;; frame 12
(defn half-addero
  [x y r c]
  (all
    (bit-xoro x y r)
    (bit-ando x y c)))