Last active
April 9, 2016 13:23
-
-
Save JAremko/90b51d1628370a915545e93776c7da2a 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 clj/->> (o &rest forms) | |
"Threads the expr through the forms. | |
Inserts o as the last item in the first form, | |
making a list of it if it is not a list already. | |
If there are more forms, inserts the first form | |
as the last item in second form, etc." | |
(cond ((not forms) o) | |
((= 1 (length forms)) | |
(let ((f (first forms))) | |
(append (if (symbolp f) | |
(list f) f) | |
(list o)))) | |
(:else `(clj/->> (clj/->> ,o ,(first forms)) ,@(rest forms))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment