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):
if len(list_of_list) == 0:
return [[]]
result = []
append = result.append
head = list_of_list[0]
tail = list_of_list[1:]
product = cartesianProduct(tail)
for v in head:
for p in product:
result += [[v] + p]
append([v] + p)
return result
# 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