Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Environment:Clojure 1.4, core.logic 0.8-alpha3
Description
When running the code:
(run* [q]
(fresh [a b c d]
(infd a b c d (domain 1 3 4 5))
(+fd b 1 a)
(+fd c 1 b)
(+fd d 1 c)
(== q [a b c d])))
I get the ouput:
([5 4 3 1])
But I would expect:
()
Because [5 4 3 1] is no sequence where the next element is always one number higher than the one before.
It seems to me like +fd behaves as it would take the next element in the domain, instead of taking the next higher number (I hope I didn't misunderstand +fd or infd).
There is workaround using membero:
(run* [q] (fresh [a b c d] (everyg #(membero % [1 3 4 5]) [a b c d]) (+fd b 1 a) (+fd c 1 b) (+fd d 1 c) (== q [a b c d])))=> ()
Note that this is quite a lot slower than it would be with infd.
(run* [q] (fresh [a b c d] (everyg #(membero % [1 3 4 5]) [a b c d]) (+fd b 1 a) (+fd c 1 b) (+fd d 1 c) (== q [a b c d])))