Programming-Idioms

History of Idiom 163 > diff from v11 to v12

Edit summary for version 12 :
New Scala implementation by user [Debaran]

Version 11

Version 12

Idiom #163 Print list elements by group of 2

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

Idiom #163 Print list elements by group of 2

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

Code
list.grouped(2).foreach(p => println(s"(${p(0)}, ${p(1)})"))