Skip to content

Instantly share code, notes, and snippets.

@lukego
Created July 17, 2020 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukego/1714405ba893250812bf522a1e4f1b97 to your computer and use it in GitHub Desktop.
Save lukego/1714405ba893250812bf522a1e4f1b97 to your computer and use it in GitHub Desktop.
(defmacro collecting (&body body)
"Evaluate BODY and return the list of values accumulated by calls to COLLECT."
(with-unique-names (collector)
`(progn (sb-int:collect ((,collector))
(flet ((collect (x) (,collector x)))
,@body)
(,collector)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment