Closed romanovamar closed 6 years ago
Ok, I get why it happens. I changed it a bit.
Lets executethe following code:
for elem in repeatntimes(itertools.count(), 2):
if elem % (10 ** 6) == 0:
print(elem)
Your implementation gets MemoryError
after about 68 million operations. This is because you spend infinite memory if your input is infinite. Try to avoid it. itertools
docs can help you
Ok, then I just use tee.
Almost ok. But I can't run your function. Please fix it
Done, I guess
Good :)
All functions except
repeatntimes
are ok.Try to test the following call and think about why it gives such result
repeatntimes(squares([1, 2, 3]), 2)