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

make-hierarchy

clojure.core

  • (make-hierarchy)
Creates a hierarchy object for use with derive, isa? etc.

1 Example top

  • ;; use make-hierarchy to build your own local hierarchy for derive, isa?, etc. 
    ;; instead of using the global hierarchy
    ;; note that the first ancestors call returns a nil since that type does not 
    ;; exist in the global hierarchy
    
    user=> (def h (make-hierarchy))
    #'user/h
    user=> (def h (derive h ::rect ::shape))
    #'user/h
    user=> (def h (derive h ::square ::rect))
    #'user/h
    user=> h
    {:parents {:user/square #{:user/rect}, :user/rect #{:user/shape}}, :ancestors {:
    user/square #{:user/shape :user/rect}, :user/rect #{:user/shape}}, :descendants
    {:user/rect #{:user/square}, :user/shape #{:user/square :user/rect}}}
    user=> (ancestors ::square)
    nil
    user=> (ancestors h ::square)
    #{:user/shape :user/rect}
    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:4367 top

(defn make-hierarchy
  "Creates a hierarchy object for use with derive, isa? etc."
  {:added "1.0"}
  [] {:parents {} :descendants {} :ancestors {}})
Vars in clojure.core/make-hierarchy: defn
Used in 0 other vars

Comments top

No comments for make-hierarchy. Log in to add a comment.