increase_elements

sequencetools.increase_elements(sequence, addenda, indices=None)

Increases sequence cyclically by addenda.

Example 1a. Increases range elements by 10 and -10 in alternation:

>>> sequencetools.increase_elements(range(10), [10, -10])
[10, -9, 12, -7, 14, -5, 16, -3, 18, -1]

Example 1b. Increases list elements by 10 and -10 in alternation:

>>> sequencetools.increase_elements(list(range(10)), [10, -10])
[10, -9, 12, -7, 14, -5, 16, -3, 18, -1]

Example 1c. Increases tuple elements by 10 and -10 in alternation:

>>> sequencetools.increase_elements(tuple(range(10)), [10, -10])
[10, -9, 12, -7, 14, -5, 16, -3, 18, -1]

Example 2. Increases pairs of elements by 0.5 starting at indices 0, 4, 8:

>>> sequence = [1, 1, 2, 3, 5, 5, 1, 2, 5, 5, 6]
>>> addenda = [0.5, 0.5]
>>> indices = [0, 4, 8]
>>> sequencetools.increase_elements(sequence, addenda, indices)
[1.5, 1.5, 2, 3, 5.5, 5.5, 1, 2, 5.5, 5.5, 6]

Returns list.