stdin, stdout, and stderr
John Gabriele
2014-02
To print to stderr:
(defn note
[& args]
(binding [*out* *err*]
(apply println args)))
Read from stdin:
(println "Enter your name:")
(def a-name (read-line))
(println (format "Hi, %s." a-name))
Note that output from println
is hot (it flushes immediately). If you wanted to have the user provide input right on the same line, use flush:
(print "Enter your name: ")
(flush)
(def a-name (read-line))
(println (format "Hi, %s." a-name))
1 Pretty Printing
(require '[clojure.pprint :as pp])
(pp/pprint some-big-data-structure)