Logo

Programming-Idioms

History of Idiom 222 > diff from v8 to v9

Edit summary for version 9 by programming-idioms.org:
[Fortran] Move comment out of snippet

Version 8

2020-04-15, 15:21:37

Version 9

2020-04-15, 15:52:22

Idiom #222 Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

Idiom #222 Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

Extra Keywords
position
Extra Keywords
position
Code
i = findloc(items, x)
if (i == 0) i = -1 ! actually unnecessary in Fortran
Code
i = findloc(items, x)
if (i == 0) i = -1
Comments bubble
The -1 part is actually unnecessary in Fortran, where array indices start at 1.