August 19, 2024
P25 - Generate a random permutation of the elements of a list
Example:* (rnd-permu '(a b c d e f))(B A D C E F)Hint: Use the solution of problem P23.
lisp
(load "p20.lisp")
(load "p23.lisp")
;;; Function that generates a random permutation of a list ;;;
(defun rnd-permu (org-list)
(if (null org-list)
()
(let ((rand-pos (+ (random (length org-list) 1)))
(cons (element-at org-list rand-pos)
(rnd-permu (org-list))