This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-11
Channels
- # architecture (3)
- # beginners (41)
- # boot (7)
- # cider (16)
- # cljs-dev (8)
- # cljsrn (2)
- # clojure (214)
- # clojure-austin (4)
- # clojure-russia (52)
- # clojure-spec (8)
- # clojure-taiwan (1)
- # clojure-uk (10)
- # clojurescript (87)
- # cursive (14)
- # datascript (34)
- # datomic (11)
- # dirac (55)
- # emacs (12)
- # hoplon (44)
- # luminus (6)
- # lumo (24)
- # off-topic (1)
- # om (8)
- # onyx (7)
- # overtone (2)
- # pedestal (1)
- # protorepl (4)
- # re-frame (7)
- # reagent (1)
- # ring (4)
- # rum (2)
- # slack-help (1)
- # spacemacs (2)
- # specter (32)
- # unrepl (131)
- # untangled (14)
- # yada (3)
Can Datalog pull groups of things satisfying some predicate about the group? For instance: sets of store-items whose prices sum to $20.
@nathansmutz I can only think of a solution for a constant size sets which is easy but not for different sizes in the same query
@nathansmutz you can do that with sub-queries, where the sub does (sum ..) and the super does the <= 20 pseudo:
[:find ?item
:where
[(datomic.api/q [:find (sum ...) ?item :where ...]) [?val ?item]]
[(<= ?val 20)]]
you’d have to figure out the right way to pass the vals from sub to super, using the appropriate :find expression etc
@robert-stuttaford Will the subquery generate all subsets of items? I don't understand the pseudo code.
apologies, i was really just showing how you’d assess aggregations in datalog by nesting queries. as for finding sets, ¯\(ツ)/¯
noticing some unexpected behavior with string tempids. this appears to be happening intermittently. when i create a tx that references another entity in the same transaction like this:
(d/transact! conn
[{:db/id "user-tempid" :user/username "mitnick"}
{:db/id "team-tempid"
:is-kind/team? true
:team/name "Test team"
:team/users #{"user-tempid"}}])
about half the time it will resolve to a ref (expected), and
the other half it will result in a literal string "user-tempid"
(unexpected) in the collection of :team/users
anyone else experienced this?
peer is 0.9.5561
and transactor is 0.9.5561
example unexpected result:
#:team{:name "Test team", :users ["user-tempid"]}
of query:
(d/q '[:find (pull ?team [:team/name :team/users]) .
:where [?team :is-kind/team? true]]
db)
Thanks @robert-stuttaford and @yonatanel . That lets me know I'm probably barking up the wrong tree with Datalog for this part of my problem. I was looking into core.logic; but it currently has trouble with arbitrarily sized sets too. It's Hammock Time
@nathansmutz Maybe with recursive rules?