Fork me on GitHub
#core-logic
<
2017-11-02
>
pbaille13:11:49

thank you @norman, i've found a way to obtain the correct solution, see this ticket if interested https://dev.clojure.org/jira/browse/LOGIC-185

pbaille13:11:13

I've got another question

pbaille13:11:30

I'm going thru the reasoned schemer and i've noticed that the order of excecution differ sometimes in core.logic. in particular 'conde' seems to behave differently, looks like it tries all branch before doing any recursion. Any toughts on this?

pbaille14:11:59

(defn pairo [x]
  (fresh [y] (firsto x y)))

(defn unwrapo [x y]
  (conde
    [(pairo x) (fresh [a] (firsto x a) (unwrapo a y))]
    [(== x y)]))

(run* [q] (unwrapo '(((pizza))) q))
; ((((pizza))) 
;  ((pizza)) 
;  (pizza) 
;  pizza
; )

;while in TRS it returns

; (pizza
;  (pizza)
;  ((pizza))
;  (((pizza)))
; )


;both:
(run 1 [q] (unwrapo q 'pizza))
;and
(run 1 [q] (unwrapo (list (list q)) 'pizza))

;returns:

;=> (pizza)

;while in TRS it returns

;=> ()

pbaille17:11:33

the wiki actually explain this difference, i've missed it, sorry