Last active
November 2, 2018 17:37
-
-
Save alandipert/9d7ff35952f33b3105f90f24a5103e48 to your computer and use it in GitHub Desktop.
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
(defun collector () | |
(let ((tail nil) | |
(head nil)) | |
(lambda (&optional (item nil item?)) | |
(cond | |
((not item?) head) | |
((null tail) (setq tail (cons item nil) | |
head tail)) | |
(t (let ((new-tail (cons item nil))) | |
(rplacd tail new-tail) | |
(setq tail new-tail))))))) | |
(let ((collect (collector))) | |
(dotimes (i 10) | |
(funcall collect i)) | |
(funcall collect)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment