3 ms·
One interesting triviality. In modern Fortran you can do "list comprehension": integer :: i integer, parameter :: n = 20 integer, dimension(n) :: i
by geoalchimista 8y ago
One interesting triviality. In modern Fortran you can do "list comprehension":
integer :: i
integer, parameter :: n = 20
integer, dimension(n) :: index = [(i, i = 1, n, 1)] ! list comp
And this works just like range(1, n+1) in Python (array index starts from 1 by default in Fortran).
The list comprehension in Fortran can even be nested (because it is essentially a do-loop), according to this Rosetta Code example:
https://rosettacode.org/wiki/List_comprehensions#Fortran https://rosettacode.org/wiki/List_comprehensions#Fortran