This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-29
Channels
- # architecture (2)
- # bangalore-clj (2)
- # beginners (177)
- # boot (1)
- # cider (36)
- # clara (15)
- # cljs-dev (30)
- # cljs-experience (6)
- # cljsrn (7)
- # clojure (94)
- # clojure-argentina (2)
- # clojure-brasil (1)
- # clojure-dusseldorf (6)
- # clojure-greece (1)
- # clojure-italy (18)
- # clojure-norway (4)
- # clojure-quebec (1)
- # clojure-russia (28)
- # clojure-sg (3)
- # clojure-spec (12)
- # clojure-turkiye (1)
- # clojure-uk (12)
- # clojurescript (169)
- # code-reviews (4)
- # community-development (2)
- # core-async (6)
- # core-matrix (6)
- # cursive (35)
- # datomic (18)
- # devcards (4)
- # euroclojure (1)
- # hoplon (2)
- # keechma (4)
- # klipse (2)
- # leiningen (1)
- # luminus (16)
- # mount (1)
- # off-topic (34)
- # om (31)
- # pedestal (6)
- # re-frame (14)
- # reagent (33)
- # specter (4)
- # uncomplicate (8)
- # unrepl (15)
- # untangled (24)
- # yada (25)
Why is this rule creating an infinite loop? I'm trying to insert a "default fact" if no other rule has yet inserted that fact. Or is there a better pattern for this?
(defrule infinite-loop
[:not [SomeFact]]
=>
(rules/insert! (map->SomeFact {:a 1})))
Also if I add {:salience -1}
to this rule, it seems to hang in the LHS? I'm not exactly sure but in any case when I set the salience a (println "looping") in the RHS fails to print and thread hangs.not sure but, i think you can: first accumulate some fact, if it's equal zero, then insert the default.
@ryanbrush Would it be ok to add a Clara channel here? https://discord.gg/v9QMy9D
@souenzzo hmm thanks, but I'm still running into an infinite loop using an accumulator and :test
to insert a default
@nkabrich Are you using (acc/count)?
[?nfacts <- (acc/count) :from SomeFact]
[:test (= 0 ?nfacts)]
@alex-dixon nope, ill give that a whirl
If an insert on the RHS causes the LHS to become false, the insert is retracted since it is no longer supported...causing the LHS to become true again and an infinite loop occurs.
The key is for the RHS insert to not match the LHS. Like check in the LHS for not a default value that the RHS could insert, so it doesn't retract the RHS inserted fact.
You can also use insert-unconditional to avoid this truth maintenance loop outright, but that can cause other headaches that depend on the order of facts inserted.
Sure thing. It's probably the biggest pitfall of rules engines like this....but can be overcome with some care
@alex-dixon I'm not familiar with that service. Let me take a look at it later today
@ryanbrush Thanks. There’s some discussion within the community to converting from Slack to it. Seems like we’re in a trial period right now. I know from the JS community that Slack’s message limit is a problem and Discord is generally looked to as the solution (they keep unlimited message history) https://github.com/reactjs/redux for example is a popular JS library that has moved to Discord