-
-
Save martinklepsch/83abda8c0b2da13d5dd4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 deterpolate [s] | |
(loop [tokens (interpolate s) | |
out-str (StringBuffer.) | |
out-args []] | |
(if (seq tokens) | |
(let [token (first tokens)] | |
(cond (string? token) | |
(recur (rest tokens) | |
(doto out-str (.append token)) | |
out-args) | |
(vector? token) | |
(recur (rest tokens) | |
(doto out-str (.append (str/join "," (map (constantly "?") token)))) | |
(into out-args token)) | |
:else | |
(recur (rest tokens) | |
(doto out-str (.append "?")) | |
(conj out-args token)))) | |
(into [(str out-str)] out-args)))) |
Author
martinklepsch
commented
Nov 11, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment