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.

fmakunbound 232<br />

var becomes greater than expr2. Each of the expressions is evaluated only<br />

once, and the to and by phrases can be written in either order.<br />

Note that the to variant appropriate for the direction of stepping must be used for<br />

the endtest to be formed correctly; that is, the code does not work if expr3<br />

is negative or O.<br />

data-type defaults to f'lXIlUtn. The keyword as is equivalent to the keyword for.<br />

Examples:<br />

(defun loop1 0<br />

(loop for i from 1 to 18<br />

collect i» => LOOP1<br />

(loop1) => (1 2 3 4 5 6 7 8 9 18)<br />

(defun loop2 0<br />

(loop for i from 8 to 5 by 1<br />

do<br />

(princ i») => LOOP2<br />

(loop2) => 812345NIL<br />

(defun loop3(inc)<br />

(loop as x from 8 by inc to (+ inc 4)<br />

do<br />

(princ x)<br />

(setq x (+ x 1»» => LOOP3<br />

(loop3 1) => 924NIL<br />

for var {data-type} from exprl downto expr2 {by expr3}<br />

To iterate downward. Performs numeric iteration. var is initialized to<br />

exprl, and on each succeeding iteration is decremented by expr3, and the<br />

endtest is adjusted accordingly.<br />

Examples:<br />

(defun loop3 0<br />

(loop for my-number from 7 by 2 downto -2<br />

do<br />

(princ my-number) (princ " H»~) => LOOP3<br />

(loop3) => 7 5 3 1 -1 NIL<br />

for var {data-type} from exprl {below expr2} {byexpr3}<br />

Loop will terminate when the variable of iteration, exprl, is greater than or<br />

equal to some terminal value, expr2.<br />

Examples:

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

Saved successfully!

Ooh no, something went wrong!