Created
December 3, 2016 22:50
-
-
Save ideal-knee/e1cf7fcdaef1a02f0d960a91d615cf9e to your computer and use it in GitHub Desktop.
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
(defmacro <-> [expr-1 expr-2 & exprs] | |
(let [expr-2-with-expr-1-let `(let ~['<- expr-1] | |
~(if (seq? expr-2) | |
expr-2 | |
`(~expr-2 ~'<-) ) )] | |
(if exprs | |
`(<-> ~expr-2-with-expr-1-let ~@exprs) | |
expr-2-with-expr-1-let ) ) ) | |
;; Example | |
(defn read-from-json-file [filename] | |
(<-> filename | |
slurp | |
(j/read-str <- :key-fn keyword) | |
(map #(update % :ts ts->datetime) <-) ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment