4 ms·
I have no idea why this is even slightly neat? Like, it's not surprising that it works, it's not clever, it's not performant, and you can't actually code like
by ltbarcly3 2y ago
I have no idea why this is even slightly neat? Like, it's not surprising that it works, it's not clever, it's not performant, and you can't actually code like this because it will overflow the stack pretty quickly. It doesn't even save lines of code.
Alternatives that aren't dumb:
for x in range(2**256): # not infinite but go ahead and run it to the end and get back to me
from itertools import repeat
for x, _ in enumerate(repeat(None)): # slightly more annoying but does work infinitely
Granted these aren't clever or non-performant enough to excite functional code fanboys.
- mrkeen 2y agoThe functional fanboys have moved onto languages that don't overflow the stack.
- dev360 1y agoSo many people neglect the lack of TCO in Python, it’s like a beginner mistake you make when you try to make your Python read like the Haskell you just learned. Not sure why you’re getting downvoted though.