Fork me on GitHub

Can someone enlighten me with some ccl result?


(run* [q]
  (fresh [a b c]
    (== q [a b c])
    (membero 1 q)
    (membero 3 q)
     [(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])))


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


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?


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


@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*.


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


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


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


would have to double-check that last one, though