Created
August 9, 2013 19:24
-
-
Save PuercoPop/6196405 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 next-candidate (candidate) | |
(labels ((iter-helper (xs &optional prev-item) | |
(if (null (first xs)) | |
(rotatef (first xs) prev-item) | |
(iter-helper (rest xs) (first xs))))) | |
(when (null (first candidate)) | |
(signal 'no-more-combinations)) | |
(iter-helper candidate))) | |
(defvar test (list 1 nil 2)) | |
(next-candidate test) | |
;; => (1 1 2) | |
;; => (nil 1 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment