mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
fix the while macro for Common Lisp
Earlier version was incorrect, as it only executed `body` once and then terminated, like an if statement instead.
This commit is contained in:
parent
a5d38aedd5
commit
6b2d8d5fe2
@ -573,13 +573,15 @@ nil ; for false - and the empty list
|
|||||||
"While `condition` is true, `body` is executed.
|
"While `condition` is true, `body` is executed.
|
||||||
|
|
||||||
`condition` is tested prior to each execution of `body`"
|
`condition` is tested prior to each execution of `body`"
|
||||||
(let ((block-name (gensym)))
|
(let ((block-name (gensym)) (done (gensym)))
|
||||||
`(tagbody
|
`(tagbody
|
||||||
|
,block-name
|
||||||
(unless ,condition
|
(unless ,condition
|
||||||
(go ,block-name))
|
(go ,done))
|
||||||
(progn
|
(progn
|
||||||
,@body)
|
,@body)
|
||||||
,block-name)))
|
(go ,block-name)
|
||||||
|
,done)))
|
||||||
|
|
||||||
;; Let's look at the high-level version of this:
|
;; Let's look at the high-level version of this:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user