This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-01
Channels
- # aleph (2)
- # beginners (137)
- # boot (4)
- # cider (10)
- # clara (29)
- # cljs-dev (71)
- # cljsrn (7)
- # clojure (105)
- # clojure-bangladesh (1)
- # clojure-france (2)
- # clojure-italy (4)
- # clojure-nl (3)
- # clojure-russia (1)
- # clojure-spec (30)
- # clojure-sweden (5)
- # clojure-uk (71)
- # clojurescript (217)
- # cursive (36)
- # data-science (1)
- # datomic (11)
- # duct (53)
- # fulcro (2)
- # garden (3)
- # jobs (1)
- # lein-figwheel (23)
- # luminus (3)
- # lumo (7)
- # mount (13)
- # off-topic (88)
- # pedestal (3)
- # re-frame (63)
- # reagent (85)
- # remote-jobs (1)
- # ring-swagger (3)
- # shadow-cljs (81)
- # spacemacs (5)
- # tools-deps (16)
- # yada (2)
So thanks to all for the help so far, but unless I can solve this "if some fact insert this other fact ONCE" problem I'm about ready to throw in the towel. It's really like I want each rule firing to be sensitive to the prior rule firings in a single call to (fire-rules), but that isn't what happens.
you absoultely are fighting the engine if you do an insert-unconditional based on an inference, but still want logical retractions. Why are you using unconditional again? i havent followed all the conversations.
that's just one way to do it, but it wouldn't work because that rule is going to fire twice and both firings will NOT see the Derived asserted by the first firing
I'm open to any reasonable way to do it, but given LHS matching those two facts I inserted, the result needs to be ONE derived.
I guess i dont understand why you need it only inserted once and not that the final state is one in the session.
Maybe all I need to do is replace the [Fact (= ?ftype ftype)] with use of an accumulator and predicate to express the "if there is some", and fire the rule once, haven't tried that
the rules don’t assume what a “duplicate” means to you or what you want to do with them. You need an extra rule to configure that yourself.
Then
(defrule merge-derived
[?all <- (acc/all) :from [::derived-intermediate (= ?ftype (-> this :derived :ftype))]]
=>
;; Merging to one, but include the count of the "duplicates" for whatever reason
(insert! (-> ?all first :derived (assoc :matches-count (count ?all))))
@dave.tenny Yep, I don’t see a reason for it there
That use of with-meta
and :type
is interesting to know about when doing type
based dispatches.
Anbody got an emacs cider clojure mode switch to adjust LHS condition indentation? My clauses don't seem to want to indent to the level of the prior clause.
@dave.tenny I agree it isn’t ideal
for multiline, I typically go with:
[WorkerViableJob
(= ?user-id user-id)
(= ?job-type job-type)]
Clojure in general I find it helps to just give up on making lines short
Most rules I’ve written have positional syntax so everything on one line works well…joins typically line up nicely. In Clara I’d probably do the same for the same reason…try to group things vertically by joins