getMethods

2011-06-23 Thread Antonio Recio
I have found a function to get the methods of the classes in the book The 
Joy of Clojure, and I would like to use it in REPL. Instead of 
java.awt.Frame I would like to specify the library that I want writing 
something like (methods any.library). Which is the way to get it?

(for [method (seq (.getMethods java.awt.Frame)) :let [method-name (.getName 
method)]] method-name)

-- 
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

Re: getMethods

2011-06-23 Thread Michael Wood
On 23 June 2011 17:04, Antonio Recio amdx6...@gmail.com wrote:
 I have found a function to get the methods of the classes in the book The
 Joy of Clojure, and I would like to use it in REPL. Instead of
 java.awt.Frame I would like to specify the library that I want writing
 something like (methods any.library). Which is the way to get it?
 (for [method (seq (.getMethods java.awt.Frame)) :let [method-name (.getName
 method)]] method-name)

You can do the above like this:

(map #(.getName %) (.getMethods java.awt.Frame))

And to turn it into a function, you just do this:

(defn class-methods [class-name]
  (map #(.getName %) (.getMethods class-name)))

-- 
Michael Wood esiot...@gmail.com

-- 
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


Re: getMethods

2011-06-23 Thread Stuart Halloway
 I have found a function to get the methods of the classes in the book The
 Joy of Clojure, and I would like to use it in REPL. Instead of
 java.awt.Frame I would like to specify the library that I want writing
 something like (methods any.library). Which is the way to get it?
 (for [method (seq (.getMethods java.awt.Frame)) :let [method-name (.getName
 method)]] method-name)
 
 You can do the above like this:
 
 (map #(.getName %) (.getMethods java.awt.Frame))
 
 And to turn it into a function, you just do this:
 
 (defn class-methods [class-name]
  (map #(.getName %) (.getMethods class-name)))

You might also want to look at clojure.reflect. The API results are data, and 
can easily be mapped/filtered/etc.

Stuart Halloway
Clojure/core
http://clojure.com

-- 
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