How about; (defn reflection-dump [o] (let [methods (seq (.getDeclaredMethods o)) ] (str o " has " (count methods) "methods...\n" (second (reduce (fn [[i st] meth] [(inc i) (str st "meth" i ": " meth "\n")]) [0 ""] methods)))))
(print (reflection-dump java.io.InputStream)) class java.io.InputStream has 9 methods meth0: public void java.io.InputStream.close() throws java.io.IOException meth1: public synchronized void java.io.InputStream.mark(int) meth2: public synchronized void java.io.InputStream.reset() throws java.io.IOException meth3: public abstract int java.io.InputStream.read() throws java.io.IOException meth4: public int java.io.InputStream.read(byte[]) throws java.io.IOException meth5: public int java.io.InputStream.read(byte[],int,int) throws java.io.IOException meth6: public long java.io.InputStream.skip(long) throws java.io.IOException meth7: public int java.io.InputStream.available() throws java.io.IOException meth8: public boolean java.io.InputStream.markSupported() - Rgds, Adrian On Fri, Jan 15, 2010 at 2:49 AM, Raoul Duke <rao...@gmail.com> wrote: > hi, > > i'm guessing there is a more Clojure-y and compact way to do this. any > suggestions would be appreciated. thank you. > > (defn reflection-dump [o] > (let [methods (.getDeclaredMethods o) > method-count (alength methods) > method-dumps (map (fn [i] (str " " i ": " (nth methods i))) (range 0 > method-count)) > method-dump-str (apply str (interpose "\n" method-dumps)) > header-str (str o " has " method-count > (cond > (= method-count 0) " methods." > (= method-count 1) " method:" > true " methods:")) > full-str (if (> method-count 0) > (concat header-str "\n" method-dump-str) > header-str)] > (apply str full-str))) > > -- > 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 > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en >
-- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en