This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-12
Channels
- # aws (3)
- # beginners (28)
- # boot (3)
- # cider (28)
- # clara (5)
- # cljs-dev (107)
- # cljsrn (1)
- # clojure (40)
- # clojure-austin (2)
- # clojure-brasil (5)
- # clojure-canada (1)
- # clojure-italy (1)
- # clojure-spec (39)
- # clojure-uk (38)
- # clojurescript (33)
- # community-development (11)
- # cursive (11)
- # datomic (43)
- # duct (6)
- # emacs (7)
- # flambo (1)
- # fulcro (68)
- # graphql (11)
- # jobs (1)
- # jobs-discuss (8)
- # leiningen (16)
- # luminus (2)
- # lumo (1)
- # off-topic (38)
- # om (2)
- # onyx (15)
- # parinfer (32)
- # portkey (5)
- # re-frame (50)
- # reagent (50)
- # reitit (1)
- # shadow-cljs (63)
- # spacemacs (10)
- # sql (27)
- # unrepl (6)
- # yada (2)
Here is simplified example of what I am trying to accomplish:
I have fact FnHolder which contains how the Temperature facts will be compared/processed. I want to have a rule which produces another fact from the FnHolder and the Temperature but it doesn't trigger the depending rules when a new Temperature which doesn't change the produced value(thus I cannot do the accumulation in the body). This behavior is similar to acc/max which does not trigger if a non-maximal Temperature is inserted. Ideally I would have been able to write the following code but it doesn't run since ?fn is not visible in the custom-accum block. Can you advice?
code
(defrecord Temperature [location temperature])
(defrecord FnHolder [location other-params])
(defrule chaning
[?fn <- FnHolder (= location ?loc)]
[?t <- (custom-accum ?fn) :from [Temperature]]
=>
;; insert facts...
)
code
@yyoncho I don’t have an immediate complete answer to that question, but perhaps you could accomplish what you are wanting with a :test
condition after the accumulation. Accumulate with something that doesn’t need to be “parameterized”.
Another possibility is to use a sort of joined fact. I’m not sure how appropriate it will be for you, but it would look like:
(defrecord Temperature [location temperature])
(defrecord FnHolder [location other-params])
(defrecord TempWithFn [temp fn-holder])
(defrule combine
[?fn <- FnHolder (= location ?loc)]
[?t <- Temperature]
=>
(insert (->TempWithFn ?t ?fn)))
(defrule chaning
[?t <- (custom-accum :fn-holder) :from [TempWithFn]]
=>
;; insert facts...
)