Two scotches later, I came up with > (defn satisfes-requirements-o [required given] > (fresh [e r s] > (membero e given) > (conso e r s) > (== s required))) >
and it seems to do the trick. I'm not sure about leaving r unbound but my tests pass. I'd love some feedback on the approach. On Friday, May 25, 2012 4:58:14 PM UTC-7, Mark wrote: > > 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@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en