17.05.2015 Views

zl:1 - FTP

zl:1 - FTP

zl:1 - FTP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

for<br />

234<br />

(defun loop-downfrom (num)<br />

(loop for x downfrom 8 by num<br />

do<br />

(print x») => LOOP-OOWNFROH<br />

(loop-downfrom 1)<br />

8<br />

7<br />

6<br />

5 ... ;infinite<br />

for var {data-type} upfrom exprl {byexpr2}<br />

Used to iterate upward with no limit.<br />

Examples:<br />

(defun loop-upfrom ()<br />

(loop for x upfrom -2 by 2<br />

do<br />

(print x») => LOOP-UPFROH<br />

(loop-upfrom)<br />

-2<br />

B<br />

2<br />

4 ... ;infinite<br />

for var {data-type} in exprl {by expr2}<br />

Iterates over each of the elements in the list exprl. If the by subclause is<br />

present, expr2 is evaluated once on entry to the loop to supply the function<br />

to be used to fetch successive sublists, instead of cdr.<br />

Examples:<br />

(defun loop1 (input-list)<br />

(loop for x in input-list<br />

for i from B<br />

do<br />

(prine (list i x»» => LOOP1<br />

(loop1 '(a b (e d) e» => (B A)(1 8)(2 (C 0»(3 E)NIL<br />

for var {data-type} on exprl {byexpr2}<br />

Like the previous for format, except that var is set to successive sublists of<br />

the list instead of successive elements. Note that since var is always a list,<br />

it is not meaningful to specify a data-type unless var is a destructuring pattern,<br />

as described in the section on destructuring. Note also that loop uses<br />

a null rather than an atom test to implement both this and the preceding<br />

clause.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!