Logo

Programming-Idioms

History of Idiom 135 > diff from v25 to v26

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

Version 25

2019-09-27, 11:03:03

Version 26

2019-09-27, 14:35:57

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Code
integer, dimension(:), allocatable :: items

i = findloc(items, x)
if (i /= 0) items = [items(1:i-1), items(i+1:)]