refactor: split parse into multiple files
Signed-off-by: Konstantin Fickel <mail@konstantinfickel.de>
This commit is contained in:
parent
082c13b046
commit
dc2a97d3b8
6 changed files with 117 additions and 92 deletions
13
src/streamer/parse/list.py
Normal file
13
src/streamer/parse/list.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from itertools import pairwise
|
||||
from typing import TypeVar
|
||||
|
||||
A = TypeVar("A")
|
||||
|
||||
|
||||
def split_at(list_to_be_split: list[A], positions: list[int]):
|
||||
positions = sorted(set([0, *positions, len(list_to_be_split)]))
|
||||
|
||||
return [list_to_be_split[left:right] for left, right in pairwise(positions)]
|
||||
|
||||
|
||||
__all__ = ["split_at"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue