You're viewing version 1.2.0 of parents. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

parents

clojure.core

  • (parents tag)
  • (parents h tag)
Returns the immediate parents of tag, either via a Java type
inheritance relationship or a relationship established via derive. h
must be a hierarchy obtained from make-hierarchy, if not supplied
defaults to the global hierarchy

1 Example top

  • ;; simple example showing single parented derivation
    ;; then adding another parent
    
    user=> (derive ::toy_poodle ::poodle)
    nil
    user=> (parents ::toy_poodle)
    #{:user/poodle}
    user=> (derive ::toy_poodle ::toy_dogs)
    nil
    user=> (parents ::toy_poodle)
    #{:user/poodle :user/toy_dogs}
    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:4421 top

(defn parents
  "Returns the immediate parents of tag, either via a Java type
  inheritance relationship or a relationship established via derive. h
  must be a hierarchy obtained from make-hierarchy, if not supplied
  defaults to the global hierarchy"
  {:added "1.0"}
  ([tag] (parents global-hierarchy tag))
  ([h tag] (not-empty
            (let [tp (get (:parents h) tag)]
              (if (class? tag)
                (into (set (bases tag)) tp)
                tp)))))
Vars in clojure.core/parents: bases class? defn into let not-empty set
Used in 1 other vars deferror

Comments top

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