Skip to content

Instantly share code, notes, and snippets.

@shakthimaan
Last active September 17, 2015 11:25
Show Gist options
  • Save shakthimaan/7682f02518b4ea787450 to your computer and use it in GitHub Desktop.
Save shakthimaan/7682f02518b4ea787450 to your computer and use it in GitHub Desktop.
Retaining i value in do loop
(setq input '(a b c d))
(setq target (number-sequence 0 (- (length a) 1)))
(defun loop-test-while(source target i)
(while (< i (length source))
(let* ((pos (random (length source)))
(element (nth pos source)))
(if (not (member element target))
(progn
(setcar (nthcdr i target) element)
(incf i)
))))
(print target))
(loop-test-while input target 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment