mikera
mikera

Reputation: 106391

Does projecting in two directions count as relational in core.logic?

I understand that project in core.logic is not relational.

However, it seems that I can get relational-like behaviour by projecting in both directions inside conda, e.g.:

(defn lifto-with-inverse
  "Lifts a unary function and its inverse into a core.logic relation."
  ([f g]
    (fn [& vs]
      (let [[x y] vs]
        (conda 
          [(pred x number?) (project [x] (== y (f x)))]
          [(pred y number?) (project [y] (== x (g y)))])))))

(let [inco (lifto-with-inverse inc dec)]
   (run* [q] (inco q 3)))
=> 2

Does this count as a relational operation? Or is there something else missing that makes this non-relational?

Upvotes: 1

Views: 143

Answers (1)

dnolen
dnolen

Reputation: 18556

It still seems like in this case one of the arguments must be ground making it non-relational.

Upvotes: 3

Related Questions