Created
October 2, 2012 02:31
-
-
Save quux00/3815846 to your computer and use it in GitHub Desktop.
Example of how to read from STDIN in a Clojure program and accumulate the entries in a vector.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example.stdin) | |
(defn do-something-cool [v] | |
(println v)) | |
(defn -main | |
"Read from STDIN" | |
[& args] | |
(println "Enter text:") | |
(loop [input (read-line) acc []] | |
(if (= ":done" input) | |
(do-something-cool acc) | |
(recur (read-line) (conj acc input)))) | |
(println "End")) |
10 years later... thanks for this! I needed it today.
11 years later... thanks for this! I needed it today.
11 years later...thanks for this! I needed it today.
12 years later...thanks for this! I needed it today.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
3 years later... thanks for this! I needed it today.