I think separating the facts from determining the hierarchy makes it easier:

(defrel typeof* p c)

(facts typeof* [[:homo :homo-sapiens]
                [:hominidae :homo]
                [:primate :hominidae]
                [:mammalia :primate]
                [:chordata :mammalia]
                [:animalia :chordata]
                [:eukarya :animalia]])

(defn typeof [p c]
  (conde
   ((typeof* p c))
   ((fresh [other-p]
           (typeof* other-p c)
           (typeof p other-p)))))

(run 1 [q]
     (typeof  :eukarya :mammalia)
     (typeof  :eukarya :primate)
     (typeof  :eukarya :hominidae)
     (== q true))

;; => (true

(run* [q]
      (typeof q :homo-sapiens))

;;=> (:homo :hominidae :primate :mammalia :chordata :animalia :eukarya)


-Ryan


On Mon, Jan 23, 2012 at 11:09 PM, David Nolen <dnolen.li...@gmail.com>wrote:

> On Tue, Jan 24, 2012 at 12:00 AM, Cedric Greevey <cgree...@gmail.com>wrote:
>
>> On Mon, Jan 23, 2012 at 11:41 PM, David Nolen <dnolen.li...@gmail.com>
>> wrote:
>> > (def homo-sapiens
>> >   {:domain :eukarya
>> >    :kingdom :animalia-metazoa
>> >    :phylum :chordata
>> >    :class :mammalia
>> >    :order :primate
>> >    :family :hominidae
>> >    :genus :homo
>> >    :species :homo-sapiens})
>>
>> Looks like putting all the transitive relations in by hand to me.
>> Ideally, once you had a genus set up you'd only have to specify that
>> various species of the genus are species of that genus, and not have
>> to specify kingdom, phylum, class, order, or family for any of them
>> explicitly.
>
>
> Sure, improvements left as an exercise for the reader ;)
>
> 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
>

-- 
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

Reply via email to