• API
• FAQ
• Tools
• Archive
daily pastebin goal
63%
SHARE
TWEET

# Untitled

whatthewhat Oct 12th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2. def build_zero_tuple(d):
3.     return tuple(0 for n2 in range(d))
4.
5. def build_mat_tuple(ctr,*args):
6.     ctr+=1
7.     if ctr == (len(args)-1):
8.         return tuple(build_zero_tuple(args[ctr]) for d in range(args[ctr]))
9.     t = tuple(build_mat_tuple(ctr,*args) for d in range(args[ctr]))
10.     return t
11.
12. def build_zero_tuple_fill(fillitems,cbox,d):
13.
14.     if (cbox[0]+d) > len(fillitems):
15.         diff = ((cbox[0]+d) - len(fillitems))
16.
17.         if diff < d:
18.             t = tuple(fillitems[cbox[0]+n] if (cbox[0]+n < len(fillitems)) else None for n in range(d))
19.         else:
20.             t = tuple(None for n in range(d))
21.     else:
22.         t= tuple(fillitems[cbox[0]+n2] for n2 in range(d))
23.     cbox[0]+=d
24.     return t
25.
26. def build_mat_tuple_fill(fillitems,cbox,ctr,*args):
27.     ctr+=1
28.     if ctr == (len(args)-1):
29.         return tuple(build_zero_tuple_fill(fillitems,cbox,args[ctr]) for d in range(args[ctr]))
30.     t = tuple(build_mat_tuple_fill(fillitems,cbox,ctr,*args) for d in range(args[ctr]))
31.     return t
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top