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

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

for pair in list.chunks(2) {
    println!("({}, {})", pair[0], pair[1]);
import std.range;
for x in zip(list[::2], list[1::2]):
list.each_slice(2){|slice| p slice}

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

Idiom created by


Related idioms