Skip to content

Instantly share code, notes, and snippets.

@trendsetter37
Created October 28, 2014 14: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 trendsetter37/54160bf21fe3235056b0 to your computer and use it in GitHub Desktop.
Save trendsetter37/54160bf21fe3235056b0 to your computer and use it in GitHub Desktop.
Gives the permutations
;; Work in progress
(defun all-permutations (list &optional (a (length list)))
"Will give you all the permutations of the list specified"
;;(format t "The optional param is: ~d~%" a)
(cond ((null list) nil)
((null (cdr list)) (list list))
(t (loop for element in list
append (mapcar (lambda (x) (cons element x))
(all-permutations (remove element list) a))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment