mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Use correct indentation.
This commit is contained in:
parent
d4c7e636a9
commit
8c81fdad33
1 changed files with 14 additions and 14 deletions
|
@ -675,17 +675,17 @@ which incur interpreter overhead.
|
|||
filtered = ifilter(operator.itemgetter(1), decorated)
|
||||
return imap(operator.itemgetter(0), filtered)
|
||||
|
||||
def combinations_with_replacement(iterable, r):
|
||||
"combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC"
|
||||
pool = tuple(iterable)
|
||||
n = len(pool)
|
||||
indices = [0] * r
|
||||
yield tuple(pool[i] for i in indices)
|
||||
while 1:
|
||||
for i in reversed(range(r)):
|
||||
if indices[i] != n - 1:
|
||||
break
|
||||
else:
|
||||
return
|
||||
indices[i:] = [indices[i] + 1] * (r - i)
|
||||
yield tuple(pool[i] for i in indices)
|
||||
def combinations_with_replacement(iterable, r):
|
||||
"combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC"
|
||||
pool = tuple(iterable)
|
||||
n = len(pool)
|
||||
indices = [0] * r
|
||||
yield tuple(pool[i] for i in indices)
|
||||
while 1:
|
||||
for i in reversed(range(r)):
|
||||
if indices[i] != n - 1:
|
||||
break
|
||||
else:
|
||||
return
|
||||
indices[i:] = [indices[i] + 1] * (r - i)
|
||||
yield tuple(pool[i] for i in indices)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue