- 769 名前:デフォルトの名無しさん mailto:sage [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)))
|

|