tree_zip#

t3toolbox.backend.stacking.tree_zip(T1, T2)#
def tree_zip(
        T1,  # nested tuples of leaves
        T2,  # nested tuples of leaves; same structure as T1
):           # same structure, each leaf a pair (t1, t2)

Zips two trees with the same structure.

Examples

>>> import t3toolbox.backend.stacking as stacking
>>> T1 = (1,(2,(3,4,5)),((6,7),8))
>>> T2 = ('a',('b',('c','d','e')),(('f','g'),'h'))
>>> print(stacking.tree_zip(T1, T2))
((1, 'a'), ((2, 'b'), ((3, 'c'), (4, 'd'), (5, 'e'))), (((6, 'f'), (7, 'g')), (8, 'h')))