Skip to content

Instantly share code, notes, and snippets.

@dpsutton
Created June 3, 2020 22:16
Show Gist options
  • Save dpsutton/d3043cdb3d30bc524a38ca6131f02a68 to your computer and use it in GitHub Desktop.
Save dpsutton/d3043cdb3d30bc524a38ca6131f02a68 to your computer and use it in GitHub Desktop.
;; thanks ghadi from #clojure.beginners
(defn into-str
"reduce coll into a String, given a transducer"
[xf coll]
(transduce (comp xf (map str))
(fn
([] (StringBuilder.))
([^StringBuilder sb] (.toString sb))
([^StringBuilder sb s] (.append sb ^String s)))
coll))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment