Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Forked from cgrand/heredoc.clj
Created February 12, 2020 08:47
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 jeroenvandijk/c50ecf43d3fb05f6f9943a18eb27b02b to your computer and use it in GitHub Desktop.
Save jeroenvandijk/c50ecf43d3fb05f6f9943a18eb27b02b 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