# insert -- copy a list, inserting an element

## Synopsis

• Usage:
insert(i, x, L)
• Inputs:
• Outputs:
• L2, , a copy of L in which x has been inserted into position i

## Description

 i1 : L = 0..10 o1 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) o1 : Sequence i2 : insert(4, "hi", L) o2 = (0, 1, 2, 3, hi, 4, 5, 6, 7, 8, 9, 10) o2 : Sequence i3 : insert(0, "hi", L) o3 = (hi, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) o3 : Sequence i4 : insert(11, "hi", L) o4 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, hi) o4 : Sequence i5 : insert(-1, "hi", L) o5 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, hi) o5 : Sequence i6 : apply({-1,-3,-5}, i -> L = insert(i, "hi", L)); L o7 = (0, 1, 2, 3, 4, 5, 6, 7, 8, hi, 9, hi, 10, hi) o7 : Sequence

## See also

• delete -- delete some elements of a list
• mingle -- mingle elements of several lists
• switch -- copy a list, switching two elements
• lists and sequences -- a detailed overview of lists and sequences in Macaulay2

## Ways to use insert :

• "insert(ZZ,Thing,VisibleList)"

## For the programmer

The object insert is .