Casper <casp...@gmail.com> writes:

> For me that leads to the question, how do we then define the relationship 
> 'descendant' (which would be the generalisation of child, grandchild etc)? 
>
> (defn child [x y]
>   (parent y x))

Ok, so you have a `child' relation already, so this should be easy (but
it's not tested):

  (defn descendant [d a]
    (conde
      [(child d a)]
      [(fresh [p]
         (child d p)
         (descendant p a))]))

So d is a descendant of a if

  - d is a child of a, or
  - there is some p who is the parent of d and a descendant of a.

I think instead of `conde' you can use `conda' here, because when the
first clause succeeds the second one cannot succeed and doesn't need to
be tested.

Bye,
Tassilo

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to