Created
April 16, 2010 04:44
-
-
Save remleduff/368018 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
; Also need to add (java.io StringReader) to :import at the top of the file | |
(defn- eval-opt | |
"Evals expressions in str, prints each non-nil result using prn" | |
[str] | |
(let [eof (Object.) | |
reader (LineNumberingPushbackReader. (StringReader. str))] | |
(loop [input (read reader false eof)] | |
(when-not (= input eof) | |
(let [value (eval input)] | |
(when-not (nil? value) | |
(prn value)) | |
(recur (read reader false eof))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment