How we can have a conditional loop in lisp ?
I know that we can dotimes for having loop but I want to have a condition : until var is not equal to "test" continue and when it equals to "test" do not continue.
conditional loop
Re: conditional loop
Check out loop macro (http://www.unixuser.org/~euske/doc/cl/loop.html, http://www.gigamonkeys.com/book/loop-fo ... belts.html)
Solution for your issue is:
where condition and form are code not loop keywords.
Solution for your issue is:
Code: Select all
(loop until condition do form)
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
-
- Posts: 166
- Joined: Sun Nov 28, 2010 4:21 pm
Re: conditional loop
Code: Select all
(defmacro until (test &body body)
`(do ()
(,test)
,@body))
;; and its companion
(defmacro while (test &body body)
`(until (not ,test)
,@body))