(defun permutations (lst) (if (null lst) (list nil) (mapcan (lambda (e) (mapcar (lambda (p) (cons e p)) (permutations (remove e lst :count 1 :test #'eq)))) lst)))