Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

arrays half-working

  • Loading branch information...
commit 73665fe2df4c241ddaa1c4aff38b7c15742004dc 1 parent 002edff
@stuarthalloway stuarthalloway authored
Showing with 25 additions and 8 deletions.
  1. +16 −3 src/mycroft/data.clj
  2. +9 −5 src/mycroft/examples.clj
View
19 src/mycroft/data.clj
@@ -18,11 +18,24 @@
(defmethod keyed clojure.lang.Sequential [obj] (indexed obj))
(defmethod keyed :default [obj] obj)
-(defmulti render-type (fn [type options] (class type)))
+(defn tag
+ [t]
+ (println "t is " t)
+ (cond
+ (nil? t) nil
+ (-> t .getClass .isArray) :Array
+ :else (class t)))
+
+(defmulti render-type (fn [type options] (tag type)))
(defmethod render-type nil [this options]
- (render-type "<nil> !!" options))
+ (render-type "&lt;nil&gt;" options))
+(defmethod render-type :Array [this options]
+ (pprint {:this this :options options})
+ (render-type (seq this) options))
(defmethod render-type java.util.Collection [this options]
(render-collection this options))
+(defmethod render-type clojure.lang.ISeq [this options]
+ (render-collection this options))
(defmethod render-type clojure.lang.IPersistentCollection [this options]
(render-collection this options))
(defmethod render-type clojure.lang.IRef [this options]
@@ -100,6 +113,7 @@
(defn composite?
[x]
(or (seq? x)
+ (-> x .getClass .isArray)
(instance? clojure.lang.Seqable x)
(instance? Iterable x)
(instance? java.util.Map x)))
@@ -113,7 +127,6 @@
(defn render-collection
[content {:keys [selector start count] :as options}]
- (pprint {:content content :selector selector})
(let [content (if selector (select content selector) content)
content (keyed content)
content (if start (drop start content) content)
View
14 src/mycroft/examples.clj
@@ -7,15 +7,19 @@
(def a-list (apply list abc))
(def a-set (set abc))
(def a-map (zipmap abc (iterate inc 1)))
+ (def an-array (into-array abc))
(def a-ref (ref abc)))
+(def some-strings
+ ["these" "are" "fine"])
+
(def a-nested-thing
{:the-atom an-atom
- :the-vector :a-vector
- :the-list :a-list
- :the-set :a-set
- :the-map :a-map
- :the-ref :a-ref})
+ :the-vector a-vector
+ :the-list a-list
+ :the-set a-set
+ :the-map a-map
+ :the-ref a-ref})
(def jmx-beans
(jmx/beans "*:*"))
Please sign in to comment.
Something went wrong with that request. Please try again.