Re: list all functions in namespace?
On Apr 4, 2014, at 7:53 PM, Christopher Howard cmhowa...@alaska.edu wrote: Is there some trick Clojure command to list all functions defined in a namespace? http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/ns-publics is a good start. --Steve -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: list all functions in namespace?
On Fri 4 Apr 2014 at 03:53:54PM -0800, Christopher Howard wrote: Is there some trick Clojure command to list all functions defined in a namespace? I use these functions to create cheatsheets on the fly: (defn fn-var? [v] (let [f @v] (or (contains? (meta v) :arglists) (fn? f) (instance? clojure.lang.MultiFn f (defn cheat-sheet [ns] (let [nsname (str ns) vars (vals (ns-publics ns)) {funs true defs false} (group-by fn-var? vars) fmeta (map meta funs) dmeta (map meta defs) flen (apply max 0 (map (comp count str :name) fmeta)) dnames (map #(str nsname \/ (:name %)) dmeta) fnames (map #(format (str %s/%- flen s %s) nsname (:name %) (string/join \space (:arglists %))) fmeta) lines (concat (sort dnames) (sort fnames))] (str ;;; nsname {{{1\n\n (string/join \newline lines which produces output like this: user= (println (cheat-sheet 'clojure.java.io)) ;;; clojure.java.io {{{1 clojure.java.io/Coercions clojure.java.io/IOFactory clojure.java.io/default-streams-impl clojure.java.io/as-file[x] clojure.java.io/as-relative-path [x] clojure.java.io/as-url [x] clojure.java.io/copy [input output opts] clojure.java.io/delete-file[f [silently]] clojure.java.io/file [arg] [parent child] [parent child more] clojure.java.io/input-stream [x opts] clojure.java.io/make-input-stream [x opts] clojure.java.io/make-output-stream [x opts] clojure.java.io/make-parents [f more] clojure.java.io/make-reader[x opts] clojure.java.io/make-writer[x opts] clojure.java.io/output-stream [x opts] clojure.java.io/reader [x opts] clojure.java.io/resource [n] [n loader] clojure.java.io/writer [x opts] Combine (cheat-sheet) with a regex filter on (all-ns), and presto, you have instant, up-to-date Clojure references on command. guns pgpy9lPrkKL1Q.pgp Description: PGP signature
Re: list all functions in namespace?
(doc dir) - clojure.repl/dir ([nsname]) Macro Prints a sorted directory of public vars in a namespace On Friday, April 4, 2014 6:53:54 PM UTC-5, Christopher Howard wrote: Is there some trick Clojure command to list all functions defined in a namespace? -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.