mightyscape-1.2/extensions/fablabchemnitz/raytracing/utils.py

12 lines
264 B
Python
Raw Normal View History

2022-10-13 00:05:56 +02:00
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)