Last active
March 6, 2021 17:16
-
-
Save cgrand/cfd0f679fdd4c89c92fa1e02cbfbee96 to your computer and use it in GitHub Desktop.
An ugly hacky heredoc for Clojure
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
(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