Created
February 11, 2013 15:28
-
-
Save lispm/4755118 to your computer and use it in GitHub Desktop.
Piping of forms in Common Lisp
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 -> (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