I am interested in solving a simple equation for all of its solutions when some constraints are applied. This sounds like a problem for core.logic.fd.
Let's use a toy example:
8 = 3*x + 2*y, where x and y must be non-negative integers.
Here are the possible solutions: [x,y]= {[2,1],[0,4]}.
I tried something like this:
(run* [q]
(fresh [x y]
(== q [x y])
(project [x y]
(fd/+ (* x 2) (y 3) 8))))
But I get a exception:
"java.lang.ClassCastException: clojure.core.logic.LVar cannot be cast to java.lang.Number"
So I have two questions:
1. How should I rewrite the above command to get the solutions?
2. Are there any good blog posts/online presentations/etc. on core.logic.fd?