SPPCompiler.Utils.Sequence module

class SPPCompiler.Utils.Sequence.SequenceUtils

Bases: object

static duplicates(seq)

Create a list of elements that are duplicates of the first element that has duplicates. For example, if the input is [1, 1, 2, 3, 3, 1], the output will be [1, 1, 1]. Note 3 isn’t included, because 1 is the first element that has duplicates.

Parameters:

seq (list[TypeVar(T)]) – The sequence to check for duplicates.

Return type:

list[TypeVar(T)]

Returns:

The list of duplicates of the first element to have duplicates.

static remove_if(seq, func)

Remove all elements from the sequence that match the predicate function.

Parameters:
  • seq (list[TypeVar(T)]) – The sequence to remove elements from.

  • func (Callable[[TypeVar(T)], bool]) – The predicate function to match against.

Return type:

None

Returns:

The modified sequence.

static print(printer, seq, *, sep)
Return type:

str

static flatten(seq)

Flatten a sequence of sequences into a single sequence.

Parameters:

seq (list[list[TypeVar(T)]]) – The sequence of sequences to flatten.

Return type:

list[TypeVar(T)]

Returns:

The flattened sequence.