conditional loop

Discussion of Common Lisp

conditional loop

Postby mparsa » Wed Jun 27, 2012 7:41 am

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.
Posts: 26
Joined: Mon Jun 25, 2012 6:15 am

Re: conditional loop

Postby Goheeca » Wed Jun 27, 2012 9:03 am

Check out loop macro (,

Solution for your issue is:
Code: Select all
(loop until condition do form)

where condition and form are code not loop keywords.
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.
User avatar
Posts: 271
Joined: Thu May 10, 2012 12:54 pm

Re: conditional loop

Postby pjstirling » Thu Jun 28, 2012 3:24 am

Code: Select all
(defmacro until (test &body body)
  `(do ()
;; and its companion
(defmacro while (test &body body)
  `(until (not ,test)
Posts: 149
Joined: Sun Nov 28, 2010 4:21 pm

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 2 guests