[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: The LOOP macro

William James

8/8/2015 5:34:00 AM

Kenny Tilton wrote:

> (loop for n below 3 do (print n))
>
> That ain't Lisp syntax. This is Lisp syntax;
>
> (do ((n 1 (1+ n)))
> ((> n 3))
> (print n))

Testing:

CL-USER(1): (loop for n below 3 do (print n))

0
1
2
NIL
CL-USER(2): (do ((n 1 (1+ n)))
((> n 3))
(print n))

1
2
3
NIL


Gauche Scheme:

(dotimes (n 3) (print n))
===>
0
1
2

Another way:

(for-each print (liota 3))
===>
0
1
2

--
The report card by the American Society of Civil Engineers showed the national
infrastructure a single grade above failure, a step from declining to the point
where everyday things simply stop working the way people expect them to. ---
washingtonpost.com/local/trafficandcommuting/us-infrastructure-gets-d-in-annual-report/2013/03/19/c48cb010-900b-11e2-9cfd-36d6c9b5d7ad_story.html