[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: loop
The file loop.cl contains the following pointer to LOOP documentation:
(I assume you overlooked this; if you did actually procure this
documentation and find it lacking, please let us know -- while we
provide the LOOP macro as is, we'd rather not point people in the
wrong direction).
;;; LOOP documentation is still probably available from the MIT Laboratory
;;; for Computer Science publications office:
;;; LCS Publications
;;; 545 Technology Square
;;; Cambridge, MA 02139
;;; It is Technical Memo 169, "LOOP Iteration Macro", and is very old. The
;;; most up-to-date documentation on this version of LOOP is that in the NIL
;;; Reference Manual (TR-311 from LCS Publications); while you wouldn't
;;; want to get that (it costs nearly $15) just for LOOP documentation,
;;; those with access to a NIL manual might photocopy the chapter on LOOP.
;;; That revised documentation can be reissued as a revised technical memo
;;; if there is sufficient demand.
;;;
Some undocumented examples that have been assembled for you -- hope they're
of some use:
<cl> (require :loop)
; Loading /hogan/usr/marketing/lwolf/loop.cl.
t
<cl> (loop:loop for i from 1 to 4 do (print i))
1
2
3
4
nil
<cl> (setf x 2 y 3)
3
<cl> (loop:loop for i from x to (+ x y)
do
(print i)
(terpri)
)
2
3
4
5
nil
<cl> (loop:loop as i from x to (+ x y)
do
(print i)
(terpri))
2
3
4
5
nil
<cl> (loop:loop for element in '(1 32 5 7)
do
(print element))
1
32
5
7
nil
<cl> (loop:loop for element in '(1 32 5 7) by #'cddr
do
(print element))
1
5
nil
<cl> (loop:loop for i from x below (+ x y)
do
(print i))
2
3
4
nil
<cl> (loop:loop for i from (+ x y) downto x
do
(print i))
5
4
3
2
nil
<cl> (loop:loop for i from (+ x y) above x
do
(print i))
5
4
3
nil
<cl> (loop:loop for i from (+ x y) above x
for element in '(1 32 5 7)
do
(print i)
(print element)
finally (return (list i element)))
5
1
4
32
3
5
(2 5)
<cl> (loop:loop for i = x then (* x i)
for j = x
with k = x
for l from 0 to 2
initially (print "hi there")
do
(setf j (* 2 j)
k (* 2 k))
(format t "~%i = ~d" i)
(format t "~%j = ~d" j)
(format t "~%k = ~d" k)
(format t "~%l = ~d" l))
"hi there"
i = 2
j = 4
k = 4
l = 0
i = 4
j = 4
k = 8
l = 1
i = 8
j = 4
k = 16
l = 2
nil
<cl> (loop:loop for i from 1 to 5
collect (* i i))
(1 4 9 16 25)
Hope this is useful!
George Jacob
Franz Inc.
- References:
- loop
- From: Jonathan Freidin <uwvax!harvard!ksr!jonathan@UCBVAX.BERKELEY.EDU>