next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: insert

insert -- copy a list, inserting an element

Synopsis

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

Ways to use insert :