Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Fortran

Idiom #277 Remove an element from a set

Remove the element e from the set x.

Explains what happens if e was already absent from x.

integer,allocatable::x(:)
integer::e=6
x=[2,4,6,8,10]
!remove 6
x=pack(x,x/=e)
(disj x e)

Removing a non-existent element from a set returns back an identical set.

New implementation...