Logo

Programming-Idioms

History of Idiom 143 > diff from v6 to v7

Edit summary for version 7 by programming-idioms.org:
New Go implementation by user [programming-idioms.org]

Version 6

2016-08-25, 22:29:48

Version 7

2016-08-26, 14:37:37

Idiom #143 Iterate alternatively over two lists

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

Idiom #143 Iterate alternatively over two lists

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

Extra Keywords
parallel
Extra Keywords
parallel
Code
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])
	}
}
Demo URL
https://play.golang.org/p/Q2_-8HxoR6