13 lines
316 B
Python
13 lines
316 B
Python
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"]
|