r/functionalprogramming • u/kinow mod • Apr 21 '25
Python Haskelling My Python
https://unnamed.website/posts/haskelling-my-python/
23
Upvotes
r/functionalprogramming • u/kinow mod • Apr 21 '25
3
u/kinow mod Apr 21 '25
Hacker News thread: https://news.ycombinator.com/item?id=43728056
7
u/josephjnk Apr 21 '25
Are Python generators stateful? I see iterators and generators used to try to simulate lazy collections pretty frequently, but in most languages they have a significant limitation in that they can’t be consumed more than once. You can put a lazy list in a variable, process it, then start over and process it a second time. When using stateful iterators if you put an iterator in a variable and try to consume it twice it will be empty on the second attempt.
3
u/11fdriver Apr 21 '25
I think there's an error in the last line of code:
Should be: