Commit ea072660 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Small optimization of cartesianProduct.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3230 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a7fb5cc4
...@@ -96,12 +96,13 @@ def cartesianProduct(list_of_list): ...@@ -96,12 +96,13 @@ def cartesianProduct(list_of_list):
if len(list_of_list) == 0: if len(list_of_list) == 0:
return [[]] return [[]]
result = [] result = []
append = result.append
head = list_of_list[0] head = list_of_list[0]
tail = list_of_list[1:] tail = list_of_list[1:]
product = cartesianProduct(tail) product = cartesianProduct(tail)
for v in head: for v in head:
for p in product: for p in product:
result += [[v] + p] append([v] + p)
return result return result
# Some list operations # Some list operations
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment