【入門】Common Lisp その3【質問よろず】
■ このスレッドは過去ログ倉庫に格納されています
0769デフォルトの名無しさん
2007/10/22(月) 18:30:51他に上手い書き方ってないでしょうか?
(defun shuffle (lst)
(labels ((shffl (lst acc)
(if (null lst)
acc
(let ((*random-state* (make-random-state t))
(len (length lst)))
(let ((rand (random len)))
(let ((nthrand (nth rand lst)))
(shffl (remove nthrand lst :count 1) (cons nthrand acc))))))))
(shffl lst nil)))
■ このスレッドは過去ログ倉庫に格納されています