I am trying to understand why the following product-pluso
function is returning unexpected results. Did I find a bug or am I misunderstanding how this works? I am using core.logic with CLP/FD. I am still learning, so I could just be doing it wrong. The function should take two factors, a number, and a sum. The sum should be the product of the factors plus the number. It works great, unless both of the factors are fresh. Then I get strange results. This is happening with core.logic v0.8.2.
(ns strang-result
(:refer-clojure :exclude [==])
(:use
clojure.test
[clojure.core.logic :exclude [is]])
(:require
[clojure.core.logic.fd :as fd]))
(defn product-pluso [factor1 factor2 number sum]
(fd/eq (= sum (+ number (* factor1 factor2)))))
(run* [x y]
(fd/in x y (fd/interval 1 38))
(product-pluso x y 2 40))
;=> ([1 38] [2 19] [3 13] [4 10] [5 8] [6 7] [7 6] [8 5] [9 5] [10 4] [11 4]
; [12 4] [13 3] [14 3] [15 3] [16 3] [17 3] [18 3] [19 2] [38 1])