Fork me on GitHub
#core-logic2015-07-27
>
tsdh09:07:22

Can someone enlighten me with some ccl result?

tsdh09:07:41

(run* [q]
  (fresh [a b c]
    (== q [a b c])
    (membero 1 q)
    (membero 3 q)
    (conde
     [(conso 1 [b c] q)]
     [(conjo [a b] 3 q)])))
;; ([1 3 _0]
;;  [1 3 3]
;;  [1 _0 3]
;;  ([1 _0 3] :- (clojure.core.logic/conjo [<lvar:a__21997> <lvar:b__21998>] 3 [1 _0 3]))
;;  [3 1 3]
;;  [1 1 3]
;;  ([_0 1 3] :- (clojure.core.logic/conjo [<lvar:a__21997> <lvar:b__21998>] 3 [_0 1 3]))
;;  ([3 _0 1] :- (clojure.core.logic/conjo [<lvar:a__21997> <lvar:b__21998>] 3 [3 _0 1]))
;;  [1 3 1]
;;  ([_0 3 1] :- (clojure.core.logic/conjo [<lvar:a__21997> <lvar:b__21998>] 3 [_0 3 1])))

tsdh09:07:41

For example, the fourth result is already subsumed by the third, and the 8th and the last result can never become true, no?

tsdh10:07:00

Another thing: Is is somehow possible to do logic programming with strings? One could use conso, resto, and appendo with lists of characters of course, but can this be done somewhat transparently so that I could define (stro a b ab) which is like appendo but translates from/to lists of characters as needed?

jballanc15:07:58

tsdh: to answer your second question first, you can always write your own string-based methods either using the core.logic primatives, or just deconstructing/reconstructing the string and using conso and friends

tsdh17:07:57

@jballanc: looking at how complicated firsto and friends are with their LCons deftype etc, reusing that seems like the way to go. However, I just wondered if I could get the conversion from/to lists of characters transparently/implicitly rather than doing it from outside of run*.

tsdh17:07:38

FWIW, I don't need to have relations on lists of characters, so that representation could be reserved for strings.

jballanc18:07:07

hmm…I think it should be possible to pass strings around…have to think about it

jballanc19:07:45

oh, and about your first question…not sure but I think what’s happening is: 1. for the 4th result, you’re swapping a and b as to which is 1 and which is unbound (`_0`) 2. for the 8th result, one of your fresh vars in the conjo is empty…I think

jballanc19:07:55

would have to double-check that last one, though