core-logic

Eugene Huang 2023-08-19T17:31:14.335969Z

Hello. Was curious if there was a recommended way to tell if a result of run has unbound lvars. For example, the result of (run 1 [q]) will return a list of 1 element with the symbol _0 . Is there an idiomatic way of checking that your result is fully bound? Is there a way to do that when the result might include that symbol in a data structure like a map?

Eugene Huang 2023-08-19T19:17:44.479619Z

FYI I settled with this for now

;; Evaluates if input is fully grounded. Returns true if input contains no core.logic symbols like `'_0`.
;; TODO: If built-in core.logic approach is found, replace this.
(defn grounded? [x]
  (not-any? (fn [x] (and (instance? clojure.lang.Symbol x)
                         (boolean (re-matches #"_\d+" (name x)))))
            (tree-seq coll? seq x)))