# switch -- copy a list, switching two elements

## Synopsis

• Usage:
switch(i, j, L)
• Inputs:
• Outputs:
• L2, a copy of the list L, with the elements in positions i and j interchanged.

## Description

A negative value of i or j is taken relative to the end of the list.

 i1 : L = 0..10; i2 : switch(3, 9, L) o2 = (0, 1, 2, 9, 4, 5, 6, 7, 8, 3, 10) o2 : Sequence i3 : switch(0, -1, L) o3 = (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0) o3 : Sequence i4 : switch(-1, -2, L) o4 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 9) o4 : Sequence

• insert -- copy a list, inserting an element
• reverse -- reverse a list or sequence
• lists and sequences -- a detailed overview of lists and sequences in Macaulay2

## Ways to use switch :

• "switch(ZZ,ZZ,VisibleList)"

## For the programmer

The object switch is .