26 May 2012 01:58
core.logic and aggregates: am i doing it wrong?
Mark <markaddleman <at> gmail.com>
2012-05-25 23:58:14 GMT
2012-05-25 23:58:14 GMT
I confess that the last time I cracked open a Prolog book was lo these many years ago in college and that I need to re-read The Art but I'm hoping that someone can point out how I'm thinking about this problem wrongly:
I'd like to write a goal that succeeds when given a set of required items and a set of supplied items, the supplied items is a proper superset of the required items. My intuition is that I want a goal that succeeds and 'returns' the common subset of the two sets and then another goal that tries to unify the subset with the required items:
(defn satisfes-requirements-o [required given]
(let [subset (run* [q]
(membero q required)
(membero q given))]
(== subset required)))
I'm basically treating the subset operation as a subrouting and using run* to aggregate the common elements. This feels wrong and it feels like I should use something less procedural but I can't wrap my brain around how else to approach the problem. Suggestions? Hints?
Thanks
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
RSS Feed