In Common Lisp it is not possible to write such a LOOP. See the LOOP Syntax.
There is a set of variable clauses on the top. But you can't use one like FOR
later in the main clause. So in an IF
clause you can't use FOR
. If you want to introduce a local variable, then you need to introduce it at the top as a WITH
clause and set it later in the body.
(loop for i in '(1 2 3)
with x
if (evenp i)
append (list)
else
do (setf x (* i i))
and append (list x))
LOOP
in Common Lisp also has no continue
feature. One would use a conditional clause.
Note, that Common Lisp has a more advanced iteration construct as a library ITERATE
. It does not exist for Emacs Lisp, though.