Programming-Idioms

History of Idiom 163 > diff from v17 to v18

Edit summary for version 18 :
New Fortran implementation by user [tkoenig]

Version 17

Version 18

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
write (*,'(2I8,:," ")') list
Comments bubble
This writes out an integer array of any length. The format string, 2I8 means two integers of eight digits each. When the format is exhausted, a new line is started (this is called "format reversion"). As an extra bonus, the space between the two integers is only printed if there is an even number of items in the array, otherwise it is skipped.