Loop over multiple arrays simultaneously: Difference between revisions

Content added Content deleted
(→‎{{header|Common Lisp}}: Added DO iterator)
Line 752: Line 752:
do (format t "~a~a~a~%" x y z))
do (format t "~a~a~a~%" x y z))
</lang>
</lang>

=== Using DO ===
<lang lisp>
(do ((x '("a" "b" "c") (rest x)) ;
(y '("A" "B" "C" "D") (rest y)) ;
(z '(1 2 3 4 6) (rest z))) ; Initialize lists and set to rest on every loop
((or (null x) (null y) (null z))) ; Break condition
(format t "~a~a~a~%" (first x) (first y) (first z))) ; On every loop print first elements
</lang>

{{out}}
<pre>
aA1
bB2
cC3
</pre>


=={{header|D}}==
=={{header|D}}==