descendants

clojure.core

  • (descendants tag)
  • (descendants h tag)
Returns the immediate and indirect children of tag, through a
relationship established via derive. h must be a hierarchy obtained
from make-hierarchy, if not supplied defaults to the global
hierarchy. Note: does not work on Java type inheritance
relationships.

1 Example top

  • ;; simple example a toy poodle is a poodle is a dog is an animal
    
    user=> (derive ::dog ::animal)
    nil
    user=> (derive ::poodle ::dog)
    nil
    user=> (derive ::toy_poodle ::poodle)
    nil
    user=> (descendants ::animal)
    #{:user/toy_poodle :user/poodle :user/dog}
    user=>
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:4917 top

(defn descendants
  "Returns the immediate and indirect children of tag, through a
  relationship established via derive. h must be a hierarchy obtained
  from make-hierarchy, if not supplied defaults to the global
  hierarchy. Note: does not work on Java type inheritance
  relationships."
  {:added "1.0"}
  ([tag] (descendants global-hierarchy tag))
  ([h tag] (if (class? tag)
             (throw (java.lang.UnsupportedOperationException. "Can't get descendants of classes"))
             (not-empty (get (:descendants h) tag)))))
Vars in clojure.core/descendants:
Used in 0 other vars

Comments top

No comments for descendants. Log in to add a comment.