Fork me on GitHub
#core-logic
<
2021-05-18
>
mrchance22:05:49

Is there a way to get all potential values for a logic var in a list? So basically a way to run this in one step? I feel like that should be obvious, but I don't see it

(let [result (run* [q] ...)]
  (run* [q]
    (membero q result)
    ...))

mrchance22:05:43

(there might be other constraints that need to access the value of result )

mrchance23:05:11

Related question: Is it possible to build prologs findall? That would provide a different way to solve the problem... I have this so far:

(defna findall [pred col result]
  ([_ [] []])
  ([_ [?x . ?rc] [?x . ?rr]]
   (pred ?x)
   (findall pred ?rc ?rr))
  ([_ [_ . ?rc] _]
   (findall pred ?rc result)))
but it's not relational, and I'm not sure it works as I would expect in all cases. (Would pass it something built with fne as pred )