I actually used infinite lists in my Python solutions this year. I can’t remember which one, but it was essentially “find the smallest number with some property”, which you can do like
next(i for i in itertools.count(1) if has_property(i))
I once gave a whole talk that was (in essence) about using Haskell-style infinite lists in Python:
I think the trick is do it with something you know well to get a feel for solving the problem, then try it in X.
Generators are great though - I used Racket’s generator support to implement the infinite spiral of day 3. I should look into doing it using the lazy language to just use regular list operations but lazily. I tried using streams but the performance was much worse - the garbage collector got overwhelmed which probably means I’m not using them correctly.
Spoken like a true Haskeller ;)
I actually used infinite lists in my Python solutions this year. I can’t remember which one, but it was essentially “find the smallest number with some property”, which you can do like
I once gave a whole talk that was (in essence) about using Haskell-style infinite lists in Python:
https://docs.google.com/presentation/d/1eI60SL3UxtWfr9ktrv48-pcIkk4S7JiDmeXGCyyGhCs/edit?usp=sharing
Not to be all self-promoting, but it’s a fun talk.
–
Anyway, good on you for doing it all in Haskell, I always aspire to try that, and then I always end up just doing it in Python.
I think the trick is do it with something you know well to get a feel for solving the problem, then try it in X.
Generators are great though - I used Racket’s generator support to implement the infinite spiral of day 3. I should look into doing it using the lazy language to just use regular list operations but lazily. I tried using streams but the performance was much worse - the garbage collector got overwhelmed which probably means I’m not using them correctly.