Kaydet (Commit) c105289e authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Simply the sample code for combinations().

üst 2ab0552b
......@@ -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
......
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