Loop over multiple arrays simultaneously: Difference between revisions

no edit summary
No edit summary
Line 453:
<lang ruby>['a','b','c'].zip(['A','B','C'], [1,2,3]).each {|a| puts a.join('')}</lang>
<code>Array#zip</code> iterates once for each element of the receiver. If an argument array is longer, the excess elements are ignored. If an argument array is shorter, the value <code>nil</code> is supplied.
 
=={{header|Scheme}}==
<lang scheme>
(map (lambda (x y z)
(begin
(display x)
(display y)
(display z)
(newline)))
'(a b c) '(A B C) '(1 2 3))
</lang>
The R5RS standard specifies that the three lists must be of the same size.
 
=={{header|Tcl}}==
Anonymous user