This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-03
Channels
- # beginners (111)
- # boot (1)
- # braveandtrue (4)
- # calva (2)
- # cider (16)
- # clara (35)
- # cljdoc (4)
- # cljs-dev (22)
- # clojure (80)
- # clojure-dev (17)
- # clojure-europe (3)
- # clojure-italy (57)
- # clojure-japan (1)
- # clojure-nl (4)
- # clojure-serbia (1)
- # clojure-spec (25)
- # clojure-uk (108)
- # clojurescript (67)
- # cursive (17)
- # data-science (5)
- # datascript (6)
- # datomic (6)
- # devcards (1)
- # events (1)
- # expound (13)
- # figwheel (2)
- # figwheel-main (6)
- # fulcro (7)
- # jobs-discuss (8)
- # kaocha (1)
- # luminus (3)
- # nrepl (6)
- # off-topic (58)
- # re-frame (1)
- # reitit (16)
- # remote-jobs (1)
- # ring (1)
- # shadow-cljs (70)
- # spacemacs (10)
- # sql (42)
- # testing (1)
- # tools-deps (8)
- # vim (1)
Couple of questions 1) I see there is no "update!" --- is retract! followed by insert! considered non-idiomatic?
In general, updating a fact would make truth maintenance really hard, if not impossible. If you find yourself retracting and inserting a fact on a right-hand-side, you are probably also going to run afoul of truth maintenance, likely by creating an infinite loop.
Logically, if a fact is no longer true because of a new piece of data, you should have an additional condition on the left-hand-side of the original rule.
2) I have a case where I take measurements of events something like {"eventX" [ (:limit 5 :prior (5 hrs)) (:limit 10 :prior (1 day)) ]} also I need to +1 those measures if they just now happened based on rule. (I don't have a list of events over that time, just the prior totals) I'm guessing the short answer is I need to "normalize the list" into individual facts and leverage insert-all! as well as use an accumulator (prior total + 1?), but then I need to accumulate and match against the limit, and how to do this with a flexible list is the part I'm not currently seeing. Particularly totaling over each period to compare against limit.
I'm not sure how you are saying :prior works. Do you want a rule to fire a rule if you get an event more than :limit in the last :prior?
so there's the existing count (from DB) if that count + (just now happened) > limit fire rule.
You've inserted multiple facts that has the database count of events of a particular type?
the final piece is maybe something like [ EventCount (?name name)(?limit limit)(?period period) (>= ?limit ( accumulate total for ?period ?name)) ; pseudocode
Assuming you aren't using an immutable, global database, you will likely have trouble with consistency if you put database calls on the left-hand-side.
ah, right. But this will have the consistency issue I'm talking about. If the count changes in the database, it will not refire a rule.
but currently we write rules and add to them if we add more periods, that sort of thing... rather have the list of periods flexible and rules take care of.
I think I need two defrecords one for name/period combo and another for keeping the count?