|
|
@ -45,6 +45,38 @@
|
|
45
|
45
|
(print (filter-ns #(.endsWith % "?") 'clojure.core))
|
|
46
|
46
|
(= (complete "take" 'clojure.core) (complete' "take" 'clojure.core))
|
|
47
|
47
|
|
|
|
48
|
(defn str-with-limit [args max-width]
|
|
|
49
|
(apply str
|
|
|
50
|
(interpose "\n" (reduce (fn [[text line] word]
|
|
|
51
|
#_(prn [line text])
|
|
|
52
|
(if (> (count (str line word)) max-width)
|
|
|
53
|
[(str text "\n" line) word]
|
|
|
54
|
[text (str line word)]))
|
|
|
55
|
["" ""]
|
|
|
56
|
args))))
|
|
|
57
|
|
|
|
58
|
(defn ls-ns [ns]
|
|
|
59
|
"List all public vars in the given namespace."
|
|
|
60
|
(print (str-with-limit (interpose " " (sort (keys (ns-publics ns)))) 80)))
|
|
|
61
|
(ls-ns 'clojure.repl)
|
|
|
62
|
|
|
|
63
|
(nth (first (re-seq (re-pattern "(.*)\n") "hey\nyou\nthere!")) 1)
|
|
|
64
|
|
|
|
65
|
(defn short-doc [sym]
|
|
|
66
|
"Returns a one-line description of the symbol."
|
|
|
67
|
(let [sym-meta (meta sym)
|
|
|
68
|
first-doc-line (nth (first (re-seq (re-pattern "(.*)\n?") (or (-> sym-meta :doc) "No documentation availlable."))) 1)]
|
|
|
69
|
(str (:ns sym-meta) "/" (:name sym-meta) " - " first-doc-line)))
|
|
|
70
|
|
|
|
71
|
(defn doc-ns [ns]
|
|
|
72
|
"Print short-doc for all vars in the given namespace."
|
|
|
73
|
(print (->> (ns-publics ns)
|
|
|
74
|
vals
|
|
|
75
|
(map short-doc)
|
|
|
76
|
sort
|
|
|
77
|
(interpose "\n"))))
|
|
|
78
|
(doc-ns 'clojure.repl)
|
|
|
79
|
|
|
48
|
80
|
(def letsample
|
|
49
|
81
|
'(let [x 10]
|
|
50
|
82
|
(+ x 3)))
|