1.2.0 permalink Arrow_down_16x16
  • (source n)
Prints the source code for the given symbol, if it can find it.
This requires that the symbol resolve to a Var defined in a
namespace for which the .clj is in the classpath.

Example: (source filter)

1 Example top

  • user=> (source max)
    ;; prints in console:
    (defn max
      "Returns the greatest of the nums."
      {:added "1.0"}
      ([x] x)
      ([x y] (if (> x y) x y))
      ([x y & more]
       (reduce max (max x y) more)))
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/repl_utils.clj:123 top

(defmacro source
  "Prints the source code for the given symbol, if it can find it.
  This requires that the symbol resolve to a Var defined in a
  namespace for which the .clj is in the classpath.
  
  Example: (source filter)"
  {:deprecated "1.2"}
  [n]
  `(println (or (get-source '~n) (str "Source not found"))))
Vars in clojure.contrib.repl-utils/source: get-source defmacro concat list or println seq str

Comments top

No comments for source. Log in to add a comment.