Logo

Programming-Idioms

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

Idiom #44 Insert element in list

Insert the element x at position i in the list s. Further elements must be shifted to the right.

Inserting the element x at a given position in the list s
integer, dimension(:), allocatable :: s

s = [s(1:i-1), x, s(i:)]
s.insert (s.begin () + i, x);

New implementation...