This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-31
Channels
- # announcements (1)
- # babashka (27)
- # beginners (107)
- # calva (2)
- # cider (1)
- # clara (1)
- # clj-kondo (17)
- # clojure (74)
- # clojure-europe (18)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (11)
- # clojure-uk (3)
- # clojurescript (10)
- # conjure (12)
- # datomic (4)
- # figwheel-main (1)
- # fulcro (28)
- # graalvm (11)
- # hugsql (12)
- # joker (1)
- # klipse (5)
- # malli (2)
- # meander (1)
- # membrane (9)
- # off-topic (26)
- # pedestal (6)
- # remote-jobs (1)
- # ring-swagger (5)
- # shadow-cljs (4)
- # test-check (14)
- # vrac (8)
- # xtdb (8)
I have sample code that I'm trying to figure out the best way to fix.
(defrecord ThingA [id data])
(defrecord ThingB [k])
(defrule broken
[ThingB
(= ?k k)]
[ThingA
(= ?id id)
(= ?data data)
(= ?entry (-> data :items (get ?k)))
(some? ?entry)]
=>
(println "entry" ?entry))
(-> (rules/mk-session)
(rules/insert (->ThingA 1 {:items {:entry {:a 1 :b 2}}}))
(rules/insert (->ThingB :entry))
(rules/fire-rules))
When I run this I get
Execution error at clara.rules.compiler/try-eval (compiler.clj:233).
Unable to resolve symbol: ?entry in this context
If I hard code the value of ?k it works, but it when I try get it from another fact I get the error.
What would be the proper way to extract a field from one fact and use it to look something up in another fact