Last active
December 30, 2015 18:09
Revisions
-
dylon revised this gist
Dec 9, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ (def h (atom (make-hierarchy))) (swap! h derive ::a ::b) ;-> "(isa? user/a user/b), under the global hierarchy: false" (println "(isa? user/a user/b), under the global hierarchy:" (isa? ::a ::b)) -
dylon renamed this gist
Dec 9, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dylon created this gist
Dec 9, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ (def h (atom (make-hierarchy))) (reset! h (derive @h ::a ::b)) ;-> "(isa? user/a user/b), under the global hierarchy: false" (println "(isa? user/a user/b), under the global hierarchy:" (isa? ::a ::b)) ;-> "(isa? user/a user/b), under the hierarchy, h: true" (println "(isa? user/a user/b), under the hierarchy, h:" (isa? @h ::a ::b)) (defmulti f identity :hierarchy h :default :unmatched) (defmethod f ::b [x] (format "I, %s, isa? user/b under f!" (print-str x))) (defmethod f :unmatched [x] (format "I, %s, am sorrowfully-not isa? user/b under f..." (print-str x))) (println (f ::b)) ;-> "I, user/b, isa? user/b under f!" (println (f ::a)) ;-> "I, user/a, isa? user/b under f!" (println (f ::c)) ;-> "I, user/c, am sorrowfully-not isa? user/b under f ..." (defmulti g identity) (defmethod g ::b [x] (format "I, %s, isa? :user/b under g!" (print-str x))) (defmethod g :default [x] (format "I, %s, am sorrowfully-not isa? :user/b under g ..." (print-str x))) (println (g ::b)) ;-> "I, user/b, isa? user/b under g!" (println (g ::a)) ;-> "I, user/a, am sorrowfully-not isa? user/b under g ..." (println (g ::c)) ;-> "I, user/c, am sorrowfully-not isa? user/b under g ..."