Logo

Programming-Idioms

History of Idiom 53 > diff from v53 to v54

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

Version 53

2019-09-26, 18:42:31

Version 54

2019-09-26, 20:13:34

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Illustration

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Illustration
Code
  write (unit=y,fmt='(*(A,:,","))') x

Comments bubble
This uses Fortran's internal write to write to the string y. The _* in the format descriptor makes sure that the format in the brackets following is repated as often as possible, and the : means skip anything afterwards (here, the comma) if there are no more I/O items.