Simply the sample code for combinations().
This commit is contained in:
parent
2ab0552b5e
commit
c105289ec4
|
@ -103,15 +103,14 @@ loops that truncate the stream.
|
|||
yield tuple(pool[i] for i in vec)
|
||||
while 1:
|
||||
for i in reversed(range(r)):
|
||||
if vec[i] == i + n-r:
|
||||
continue
|
||||
vec[i] += 1
|
||||
for j in range(i+1, r):
|
||||
vec[j] = vec[j-1] + 1
|
||||
yield tuple(pool[i] for i in vec)
|
||||
break
|
||||
if vec[i] != i + n - r:
|
||||
break
|
||||
else:
|
||||
return
|
||||
vec[i] += 1
|
||||
for j in range(i+1, r):
|
||||
vec[j] = vec[j-1] + 1
|
||||
yield tuple(pool[i] for i in vec)
|
||||
|
||||
.. versionadded:: 2.6
|
||||
|
||||
|
|
Loading…
Reference in New Issue