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

Idiom #143 Iterate alternatively over two lists

Iterate alternatively over the elements of the list items1 and items2. For each iteration, print the element.

Explain what happens if items1 and items2 have different size.

import std.range;
import std.algorithm.iteration;
import std.stdio;
roundRobin(items1, items2).each!writeln;
for i := 0; i < len(items1) || i < len(items2); i++ {
	if i < len(items1) {
		fmt.Println(items1[i])
	}
	if i < len(items2) {
		fmt.Println(items2[i])
	}
}
interweave :: [a] -> [a] -> [a]   -- optional signature
interweave [] ys = ys
interweave xs [] = xs
interweave (x:xs) (y:ys) = x : y : interweave xs ys

main = mapM_ print $ interweave items1 items2
for pair in zip(item1, item2): print(pair)
items1.zip(items2){|pair| puts pair}
extern crate itertools;
for pair in izip!(item1, item2) {
    println!("{:?}", pair);
}
(map (lambda (x)
       (display x)
       (newline))
     (foldr append '()
            (map list items1 items2)))

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