Kaydet (Commit) 8c81fdad authored tarafından Georg Brandl's avatar Georg Brandl

Use correct indentation.

üst d4c7e636
......@@ -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)
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