Skip to content

Instantly share code, notes, and snippets.

@fmnoise
Forked from cgrand/heredoc.clj
Created January 26, 2019 16:13
Show Gist options
  • Save fmnoise/16fbbb6b5675c5195c0da1fd47e3d97f to your computer and use it in GitHub Desktop.
Save fmnoise/16fbbb6b5675c5195c0da1fd47e3d97f to your computer and use it in GitHub Desktop.
An ugly hacky heredoc for Clojure
(defn heredoc []
(let [delim (.readLine *in*)]
(->> (repeatedly #(.readLine *in*))
(take-while #(not= delim %))
(interpose \newline)
(apply str))))
; The following lines are read (by the reader) as:
; "Look )(\"\\T\na here doc!\n"
#=(heredoc)"""
Look )("\T
a here doc!
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment