Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created August 9, 2013 19:24
Show Gist options
  • Save PuercoPop/6196405 to your computer and use it in GitHub Desktop.
Save PuercoPop/6196405 to your computer and use it in GitHub Desktop.
(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