Loop over multiple arrays simultaneously: Difference between revisions
Loop over multiple arrays simultaneously (view source)
Revision as of 12:49, 10 November 2020
, 3 years ago→{{header|Raku}}: add a roundrobin example
No edit summary |
Thundergnat (talk | contribs) (→{{header|Raku}}: add a roundrobin example) |
||
Line 2,867:
<lang perl6>for <a b c d>.kv -> $i, $letter { ... }</lang>
=== Iterate until all exhausted ===
If you have different sized lists that you want to pull a value from each per iteration, but want to continue until '''all''' of the lists are exhausted, we have <code>roundrobin</code>.
<lang perl6>.put for roundrobin <a b c>, 'A'..'G', ^5;</lang>
{{out|yields}}
<pre>a A 0
b B 1
c C 2
D 3
E 4
F
G</pre>
=={{header|Red}}==
|