This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-16
Channels
- # beginners (7)
- # boot (63)
- # capetown (1)
- # cider (20)
- # clara (15)
- # cljs-dev (5)
- # clojure (195)
- # clojure-austria (2)
- # clojure-dev (46)
- # clojure-dusseldorf (9)
- # clojure-germany (6)
- # clojure-greece (36)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-russia (173)
- # clojure-sg (1)
- # clojure-spec (93)
- # clojure-uk (65)
- # clojure-ukraine (2)
- # clojured (9)
- # clojureremote (1)
- # clojurescript (52)
- # core-async (14)
- # core-logic (5)
- # cursive (21)
- # data-science (8)
- # datomic (60)
- # emacs (83)
- # jobs (9)
- # jobs-discuss (7)
- # juxt (6)
- # klipse (2)
- # leiningen (1)
- # lumo (24)
- # mount (4)
- # numerical-computing (1)
- # off-topic (18)
- # om (37)
- # om-next (5)
- # onyx (13)
- # pedestal (1)
- # perun (44)
- # proton (2)
- # rdf (3)
- # re-frame (24)
- # reagent (4)
- # remote-jobs (3)
- # spacemacs (3)
- # testing (6)
- # vim (10)
- # yada (2)
Could anyone be so kind as to help me understand how variable definition works? This is the most concise example I have to illustrate my confusion.
(require '[clara.rules :as rule])
(rule/defrule wat
[1 (= ?a "a")]
[1 (= ?b "b")
(nil? (println ?a)) ;; => "a"
(nil? (println ?b)) ;; => "b"
(nil? (println ?a ?b)) ;; => "a nil"
] => nil)
(-> (rule/mk-session [wat] :fact-type-fn (constantly 1))
(rule/insert 1)
(rule/fire-rules))
Why does ?b
disappear when printed together with ?a
?
I wouldn’t expect that to happen, but I can see the behavior you describe when I drop your example in a REPL
It is a weird case in that you’d normally expect the bindings to come off the actual fact in some way, but it still seems like incorrect behavior at first glance, probably merits a GitHub issue
I was experiencing the behavior with a more traditional rule in my application. This above was as too the point of an example to demonstrate it as possible. I will open a issue on GitHub.
i know ive had issues when i try to refer to a binding in the same condition (might be the wrong term) where it was bound.
I suspect that the reason adding ?a causes ?b to be different is that if you have ?a in the constraint it will become a join with the previous fact, and if it is absent it is a condition on a single fact