Skip to content

Instantly share code, notes, and snippets.

/recur not tail Secret

Created August 19, 2014 01:26
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 anonymous/ef919ea2b636d40b5efc to your computer and use it in GitHub Desktop.
Save anonymous/ef919ea2b636d40b5efc to your computer and use it in GitHub Desktop.
(defn recur-not-tail
[din loop]
(let [stream-buf (byte-array 0xFFF)
baos (java.io.ByteArrayOutputStream.)]
(loop []
(let [read-bytes (.read din stream-buf 0 0xFFF)]
(if (= -1 read-bytes)
nil
(do (.write baos 0 read-bytes)
(recur)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment