Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: