zamotivator

Untitled

May 9th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. def box_iter(self):
  2. # 1) from every dimension receive the range list like: [ (0, 1), (1, 2), ... ]
  3. # 2) product range lists like: [ ((0,1), (0,1)), ((1,2), (1,2)), ... ]
  4. # 3) recompound to min/max [ ([0,0], [1,1]), ([1,1], [2,2]), ... ]
  5. # 4) create vectors [ [Vector([0, 0]), Vector([1, 1])], [Vector([1,1]), Vector([2,2])], ... ]
  6. # 5) create boxes [ Box(Vector([0, 0], Vector[1, 1])), Box(Vector([1,1]), Vector([2,2])), ... ]
  7. def box(pair):
  8. return Box(Vector(pair[0]), Vector(pair[1]))
  9. return imap(box, imap(lambda a: zip(*a), product(*reversed(list(self)))))
Advertisement
Add Comment
Please, Sign In to add comment