Skip to content

Instantly share code, notes, and snippets.

@lispm
Created July 23, 2015 12:10
Show Gist options
  • Save lispm/5604501cdaa52456ee58 to your computer and use it in GitHub Desktop.
Save lispm/5604501cdaa52456ee58 to your computer and use it in GitHub Desktop.
Pipe, threading, sequencing expressions in Common Lisp
(defmacro pipe (expression &rest expressions)
(if (null expressions)
expression
(destructuring-bind ((fn arg &rest args) &rest more-expressions)
expressions
`(pipe
(let ((,arg ,expression))
(,fn ,arg ,@args))
,@more-expressions))))
(defmacro pipe (expression &rest expressions)
(if (null expressions)
expression
(destructuring-bind ((fn arg &rest args) &rest more-expressions)
expressions
(declare (ignorable arg))
`(pipe
(,fn ,expression ,@args)
,@more-expressions))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment