This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/raytracing/utils.py
2021-10-24 19:19:52 +02:00

12 lines
264 B
Python

import itertools
from typing import TypeVar, Iterator, Tuple
T = TypeVar("T")
def pairwise(iterable: Iterator[T]) -> Iterator[Tuple[T, T]]:
"""s -> (s0,s1), (s1,s2), (s2, s3), ..."""
a, b = itertools.tee(iterable)
next(b, None)
return zip(a, b)