Logo

Programming-Idioms

History of Idiom 163 > diff from v17 to v18

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

Version 17

2019-09-27, 21:44:33

Version 18

2019-09-27, 22:31: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
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.