On Thu, Nov 6, 2008 at 8:25 AM, Chanwoo Yoo <[EMAIL PROTECTED]> wrote: > > Hi all. In Stuart's book - Programming Clojure, there is a multi > method like following: > > (defmulti blank? class) > (defmethod blank? String [s] (every? #{\space} s)) > (defmethod blank? nil [_] true) > > After reading the method, I was curious about type or class of native > data structures of Clojure. So I typed next code in slime. Hmm.. I > didn't understand why classes of {:a 1} and {} are not same. Like > Stuart's code, to make multi method branching based on clojure data > structure type(map, vector, list), what symbol should I use? (Like > String for "string", Is there a Map for {:a 1}? I tried > PersistentHashMap, HashMap, Map, so on.. I didn't find it.)
I think what you're looking for is "clojure.lang.PersistentHashMap" instead of just "PersistentHashMap". user=> String java.lang.String user=> PersistentHashMap java.lang.Exception: Unable to resolve symbol: PersistentHashMap in this context [...] user=> clojure.lang.PersistentHashMap clojure.lang.PersistentHashMap user=> I don't know much about Clojure, though, so I suspect there is better advice than the above :) > user> (= (class "abc") String) > true > user> (class {:a 1 :b 2}) > #=clojure.lang.PersistentHashMap > user> (class {}) > #=clojure.lang.PersistentHashMap > user> (= (class {:a 1}) (class {})) > false > user> (= (class {:a 1}) (class {:b 2})) > true That seems rather strange to me too. -- Michael Wood <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---