Skip to content

Instantly share code, notes, and snippets.

@JAremko
Last active April 9, 2016 13:23
Show Gist options
  • Save JAremko/90b51d1628370a915545e93776c7da2a to your computer and use it in GitHub Desktop.
Save JAremko/90b51d1628370a915545e93776c7da2a to your computer and use it in GitHub Desktop.
(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