Loops/For with a specified step: Difference between revisions
Content deleted Content added
SantiagoPiM (talk | contribs) →{{header|Common Lisp}}: Added DO iterator |
|||
Line 592:
<pre>
2, 4, 6, 8, who do we appreciate?
</pre>
=== Using DO ===
<lang lisp>
(do ((n 0 (incf n (+ (random 3) 2)))) ; Initialize to 0 and set random step-value 2, 3 or 4
((> n 20)) ; Break condition
(print n)) ; On every loop print value
</lang>
{{out}}
<pre>
0
4
6
8
12
16
18
</pre>
|