Created
October 28, 2014 14:33
-
-
Save trendsetter37/54160bf21fe3235056b0 to your computer and use it in GitHub Desktop.
Gives the permutations
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
| ;; 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