You need to core.logic/project
logic vars into non-relational goals, like the normal function count-different-elements-in-list
. Unfortunately, you cannot project
finite domain logic vars, like a
, b
, and c
, that are not constrained to a single value. (See: this question)
In the example you have, you can swap out the fd/in
and fd/interval
for a generated range and membero
. This would remove the unconstrained finite domain vars, keep the range constraint for integers, and allow for projection.
(def interval (vec (range 1 4)))
(run* [a b c]
(membero a interval)
(membero b interval)
(membero c interval)
(project [a b c]
(== 2 (count-different-elements-in-list (list a b c)))))