Fixup itertools recipe to cover a corner case.
This commit is contained in:
parent
badbba4f99
commit
cdc9f2c1d5
|
@ -686,6 +686,8 @@ which incur interpreter overhead.
|
|||
# number items returned: (n+r-1)! / r! / (n-1)!
|
||||
pool = tuple(iterable)
|
||||
n = len(pool)
|
||||
if not n and r:
|
||||
return
|
||||
indices = [0] * r
|
||||
yield tuple(pool[i] for i in indices)
|
||||
while 1:
|
||||
|
|
|
@ -1268,6 +1268,8 @@ Samuele
|
|||
... "combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC"
|
||||
... pool = tuple(iterable)
|
||||
... n = len(pool)
|
||||
... if not n and r:
|
||||
... return
|
||||
... indices = [0] * r
|
||||
... yield tuple(pool[i] for i in indices)
|
||||
... while 1:
|
||||
|
|
Loading…
Reference in New Issue