I'm using core logic to get a list of things, and infer properties about them. No answers (`nil`) is a perfectly valid answer, but I don't want to throw away an item which doesn't have an answer for a particular question. How can I do this?
user=> (l/run* [q] (l/== q nil))
(nil)
user=>
@hiredman I've potentially already got an answer for my question though, so I can't do that.
user=> (l/run* [q] (l/conde [(l/== q nil)] [(l/!= q nil)]))
(nil (_0 :- (!= (_0 nil))))
user=>
@hiredman Thanks, that led me to my solution.
(l/run*
[x q]
(l/== x 10)
(fn [a]
(l/to-stream [])))
I have a case where this could happen. How can I detect that q hasn't been bound and mark it as nil, so that I still get an answer about x?do you really really really really need to check if x is "fresh" (i guess thats what you mean with unbound)? ;; Following code loses relational properties (conde [(lvaro q) ;; q is fresh... ] [(nonlvaro q) ;; q is not fresh ])