MCPcopy Index your code
hub / github.com/omkarcloud/botasaurus / iterflatten

Function iterflatten

botasaurus/list_utils.py:1–8  ·  view source on GitHub ↗

Iteratively flatten a list shallowly or deeply.

(array, depth=-1)

Source from the content-addressed store, hash-verified

1def iterflatten(array, depth=-1):
2 """Iteratively flatten a list shallowly or deeply."""
3 for item in array:
4 if isinstance(item, (list, tuple)) and depth != 0:
5 for subitem in iterflatten(item, depth - 1):
6 yield subitem
7 else:
8 yield item
9
10def flatten_depth(array, depth=1):
11 """

Callers 1

flatten_depthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected