remove_elements

sequencetools.remove_elements(sequence, indices=None, period=None)

Removes sequence elements at indices.

Sequence for examples:

>>> sequence = list(range(15))

Example 1. Removes all elements:

>>> sequencetools.remove_elements(sequence)
[]

Example 2. Removes elements and indices 2 and 3:

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[2, 3],
...     )
[0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

Example 3. Removes elements and indices -2 and -3:

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[-2, -3],
...     )
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14]

Example 4. Removes elements and indices 2 and 3 (mod 4):

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[2, 3],
...     period=4,
...     )
[0, 1, 4, 5, 8, 9, 12, 13]

Example 5. Removes elements at indices -2 and -3 (mod 4):

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[-2, -3],
...     period=4,
...     )
[2, 3, 6, 7, 10, 11, 14]

Example 6. Removes no elements:

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[],
...     )
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

Example 7. Removes no elements:

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[97, 98, 99],
...     )
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

Example 8. Removes no elements:

>>> sequencetools.remove_elements(
...     sequence,
...     indices=[-97, -98, -99],
...     )
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

Example 9. Removes tuple elements at indices -2 and -3 (mod 4):

>>> sequencetools.remove_elements(
...     tuple(sequence),
...     indices=[-2, -3],
...     period=4,
...     )
(2, 3, 6, 7, 10, 11, 14)

Returns elements in the order they appear in sequence.

Returns new object of sequence type.