Skip to content

Instantly share code, notes, and snippets.

@lispm
Created February 11, 2013 15:28
Show Gist options
  • Save lispm/4755118 to your computer and use it in GitHub Desktop.
Save lispm/4755118 to your computer and use it in GitHub Desktop.
Piping of forms in Common Lisp
(defmacro -> (form &rest forms)
(loop with result = form
with next-form = nil
while forms
do (setf next-form (pop forms))
(if (consp next-form)
(setf result (destructuring-bind (function . args) next-form
`(,function ,result ,@args)))
(setf result `(,next-form ,result)))
finally (return result)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment