nivs

Decart

Feb 4th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. t = [[1, 2, 3], ['a', 'b', 'c'], ['_1', '_2', '_3'], ['_a', '_b', '_c']]
  2.  
  3. def dec(a, b):
  4.     buf = [[]]
  5.     e = 0
  6.     for i in a:
  7.         for j in b:
  8.             if not isinstance(i, list): i = [i]
  9.             if not isinstance(j, list): j = [j]
  10.             buf[e] = i + j
  11.             if not e == len(a) * len(b) - 1:
  12.                 buf.append([])
  13.             e += 1
  14.     return buf
  15.  
  16. g = dec(t[0], t[1])
  17. for i in t[2:]:
  18.     g = dec(g, i)
Advertisement
Add Comment
Please, Sign In to add comment