amaranth/nmigen/tools.py
2018-12-12 03:18:44 +00:00

23 lines
335 B
Python

from collections import Iterable
__all__ = ["flatten", "union"]
def flatten(i):
for e in i:
if isinstance(e, Iterable):
yield from flatten(e)
else:
yield e
def union(i):
r = None
for e in i:
if r is None:
r = e
else:
r |= e
return r