updated from Atlas
This commit is contained in:
14
attic/iterables/aritprog_v4.py
Normal file
14
attic/iterables/aritprog_v4.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# BEGIN ARITPROG_ITERTOOLS
|
||||
import itertools
|
||||
|
||||
|
||||
def aritprog_gen(begin, step, end=None):
|
||||
if end is not None and begin >= end:
|
||||
return
|
||||
yield type(begin + step)(begin)
|
||||
tail_gen = itertools.count(begin+step, step)
|
||||
if end is not None:
|
||||
tail_gen = itertools.takewhile(lambda n: n < end, tail_gen)
|
||||
for x in tail_gen:
|
||||
yield x
|
||||
# END ARITPROG_ITERTOOLS
|
||||
13
attic/iterables/aritprog_v5.py
Normal file
13
attic/iterables/aritprog_v5.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# BEGIN ARITPROG_ITERTOOLS
|
||||
import itertools
|
||||
|
||||
|
||||
def aritprog_gen(begin, step, end=None):
|
||||
if end is not None and begin >= end:
|
||||
return
|
||||
yield type(begin + step)(begin)
|
||||
tail_gen = itertools.count(begin+step, step)
|
||||
if end is not None:
|
||||
tail_gen = itertools.takewhile(lambda n: n < end, tail_gen)
|
||||
yield from tail_gen
|
||||
# END ARITPROG_ITERTOOLS
|
||||
Reference in New Issue
Block a user