This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-05
Channels
- # adventofcode (95)
- # announcements (3)
- # babashka (11)
- # beginners (39)
- # boot (19)
- # bristol-clojurians (1)
- # cider (32)
- # clj-kondo (39)
- # cljsrn (8)
- # clojure (156)
- # clojure-dev (35)
- # clojure-europe (4)
- # clojure-italy (15)
- # clojure-nl (28)
- # clojure-spec (43)
- # clojure-uk (153)
- # clojurescript (168)
- # core-async (13)
- # core-logic (11)
- # cryogen (4)
- # cursive (13)
- # datomic (26)
- # duct (3)
- # emacs (8)
- # fulcro (33)
- # garden (4)
- # graalvm (18)
- # graphql (4)
- # jobs-discuss (2)
- # kaocha (1)
- # leiningen (3)
- # malli (8)
- # off-topic (1)
- # pathom (7)
- # re-frame (21)
- # reagent (3)
- # rewrite-clj (1)
- # schema (4)
- # shadow-cljs (40)
- # sql (2)
- # uncomplicate (3)
See distinct
under https://github.com/clojure/core.logic/wiki/Features#clpfd
I assume that’s what you are looking for.
That's only for fd
logic variables though, I would think the question was equivalent to "at most one pair out of the 6 lvars can unify"
Can't think of an easy way to express that (besides macroexpanding all the permutations by brute force)
Oh yes, good point. I interpreted the question rather as “I know which 5 of the 6 lvars should be distinct”.
What about defining something like this: (untested)
(defnc 5-distinct [a b c d e f]
(= 5 (count (set [a b c d e f]))))
and then using that as a goal inside run
?hi I’m getting a weird error in the repl as I work through the core.logic getting started. I’m on jDK 11, wondering if it’s module related
(l/run* [q]
(l/fresh [a]
(l/membero a [1 2 3])
(l/membero q [3 4 5])
(== a q)))
Error printing return value (ClassCastException) at clojure.lang.Numbers/equiv (Numbers.java:238).
class clojure.core.logic.LVar cannot be cast to class java.lang.Number (clojure.core.logic.LVar is in unnamed module of loader clojure.lang.DynamicClassLoader @11da06db; java.lang.Number is in module java.base of loader 'bootstrap')