This language bar is your friend. Select your favorite languages!

Idiom #141 Iterate in sequence over two lists

Iterate in sequence over the elements of the list items1 then items2. For each iteration print the element.

(map (lambda (x)
       (display x)
     (append items1 items2))
import std.range;
import std.algorithm.iteration;
import std.stdio;
chain(items1, items2).each!writeln;
for _, v := range items1 {
for _, v := range items2 {
mapM_ print $ items1 ++ items2
for i := 0 to items1.Count-1 do writeln(items1[i]);
for i := 0 to items2.Count-1 do writeln(items2[i]);
for x in items1 + items2:
[items1, items2].each{|ar| ar.each{|item| p item }}
items1.chain(items2).each{|item| puts item}
for i in item1.chain(item2) {
    print!("{} ", i);

Do you know the best way to do this in your language ?
New implementation...

Idiom created by


Related idioms