Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » switch
next | previous | forward | backward | up | index | toc

switch -- copy a list, switching two elements

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

See also

Ways to use switch:

  • switch(ZZ,ZZ,BasicList)

For the programmer

The object switch is a method function.


The source of this document is in Macaulay2Doc/functions/switch-doc.m2:32:0.