Get the source of clojure.zip -


obviously, can go clojure's github page or in maven repository, not question literally getting source code.

i want programmatically top level forms defined in namespace.

(get-top-level-forms-of 'clojure.zip) 

=>

['(ns ^{:doc "functional hierarchical zipper, navigation, editing,   , enumeration.  see huet"        :author "rich hickey"}   clojure.zip   (:refer-clojure :exclude (replace remove next)))   '(defn zipper   "creates new zipper structure.     branch? fn that, given node, returns true if can have   children, if doesn't.    children fn that, given branch node, returns seq of   children.    make-node fn that, given existing node , seq of   children, returns new branch node supplied children.   root root node."   {:added "1.0"}   [branch? children make-node root]     ^{:zip/branch? branch? :zip/children children :zip/make-node make-node}     [root nil])   '(defn seq-zip   "returns zipper nested sequences, given root sequence"   {:added "1.0"}   [root]     (zipper seq?             identity   .....__all_the_rest_of_the_forms_in_clojure.zip_....] 

basically, getting ordered sequence of forms in namespace, in order defined. possible?

this extract top-level forms copy of clojure.zip source bundled inside clojure jar:

(require '[clojure.java.io :as io])  (let [rdr (clojure.lang.linenumberingpushbackreader.            (io/reader (io/resource "clojure/zip.clj")))       sentinel (object.)]   (take-while #(not (identical? sentinel %))               (repeatedly #(read rdr false sentinel)))) ;= ((ns clojure.zip (:refer-clojure :exclude (replace remove next))) ...) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -