lisp - loop keyword immediately after finally -
when had asked how get numbers lottery given hint create function shuffles list. tried so, , got working.
my current implementation looks this:
(defun shuffle (list) (let ((len (length list))) (loop repeat len (rotatef (nth (random len) list) (nth (random len) list)) return list))) good news works:
(shuffle '(1 2 3 4 5 6)) ;; => (3 1 4 2 6 5) bad news error message:
warning: loop: loop keyword after finally: permitted cltl2, forbidden ansi cl.
unfortunately don't understand it. why tell me loop appears after finally? and, what's wrong code causes this?
is there better way formulate this?
warning: loop: loop keyword after finally: permitted cltl2, forbidden ansi cl.
this means return loop keyword, not allowed after finally, according ansi cl standard.
if want return loop, need use return macro:
(loop ... (return list)) it's common mistake. finally return <expr> no longer allowed since ansi cl standard. that's reason not use cltl2 (common lisp language, 2nd edition) reference. cl hyperspec better reference.
Comments
Post a Comment