polymerist.genutils.sequences.seqops
Generic operations for indexing, generating, and iterating over sequences
Attributes
Functions
|
Whether or not a Sequence contains repeating items |
|
Generate ordered non-negative integers which don't appear in a sequence of integers |
|
Pad a given list with a particular value |
|
Cyclically shift all items in a sequence over by the target number of indices |
Module Contents
- polymerist.genutils.sequences.seqops.T
- polymerist.genutils.sequences.seqops.S
- polymerist.genutils.sequences.seqops.is_unique(seq: Sequence) bool[source]
Whether or not a Sequence contains repeating items
- polymerist.genutils.sequences.seqops.int_complement(integers: Sequence[int], bounded: bool = False) Generator[int, None, None][source]
Generate ordered non-negative integers which don’t appear in a sequence of integers
- polymerist.genutils.sequences.seqops.pad_sequence(target_list: Sequence[T], to_length: int, pad_value: S = 0, from_left: bool = False) list[T | S][source]
Pad a given list with a particular value
- polymerist.genutils.sequences.seqops.cycle_items(seq: Sequence[T], places: int = 1) list[T][source]
Cyclically shift all items in a sequence over by the target number of indices By default shifts right, but can also move to left with negative “places” argument
- Examples:
cycle_items([1,2,3,4], 2) -> [3,4,1,2] cycle_items([1,2,3,4], -1) -> [4,1,2,3]