Skip to content

Instantly share code, notes, and snippets.

@remleduff
Created April 16, 2010 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remleduff/368018 to your computer and use it in GitHub Desktop.
Save remleduff/368018 to your computer and use it in GitHub Desktop.
; 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