On Tue, Oct 30, 2012 at 8:58 PM, Anthony Rosequist < anthony.rosequ...@gmail.com> wrote:
> (conde > [(!= person1 person2)] > [(<=fd start2 start1) (<=fd end2 start1)] > [(<=fd end1 start2) (<=fd end1 end2)]) > Here's a version that at least guarantees that people aren't appearing in the task list right after themselves. (defrel person id) (defrel task id start end duration) (facts person [['A] ['B]]) (facts task [[1 0 10 5] [2 0 10 9] [3 0 11 3]]) (defne personso [q] ([()]) ([[[_ p _ _] . r]] (person p) (personso r))) (defne time-intervalso [q lp] ([() _]) ([[[_ a _ _]] [_ b _ _]] (!= a b)) ([[[ta a as ae] bv . r]] (matche [bv] ([[tb b bs be]] (!= a b) (time-intervalso r bv))))) (let [data [[1 (lvar) (lvar) (lvar)] [2 (lvar) (lvar) (lvar)] [3 (lvar) (lvar) (lvar)]]] (run* [q] (== q data) (personso q) (time-intervalso q (lvar)))) ;; ([[1 A _.0 _.1] [2 B _.2 _.3] [3 A _.4 _.5]] [[1 B _.0 _.1] [2 A _.2 _.3] [3 B _.4 _.5]]) Even so I don't really understand the time conditions you've described at all. Can you please clarify or draw a simple picture with text what results you are expecting? I'm a bit confused by your task facts in particular, for example start 0, end 10 but duration 5 ??? Thanks, David -- 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