News for hackers. Stuff that matters.
Re:Infinite work is less work by anandology on Thursday July 11, 2019 @01:42PM (#20413622)
I think Infinity can be handled lot more elegantly in Python.

Here is my response with the same problem solved in Python.

https://anandology.com/blog/python-is-infintely-beautiful/

Re:Infinite work is less work by roberto on Thursday July 11, 2019 @02:50PM (#20414286)
You can replace your `integers` function with `itertools.count` (same signature but defaults to starting at 0), and `take` with `itertools.islice`.
Re:Infinite work is less work by anandology on Thursday July 11, 2019 @08:44PM (#20417191)
Didn't realize I could use `itertools.count`. In fact, it accepts a `start` parameter.

The `take` function is borrowed from Haskell. It feels lot more natural to say/read `take(10, primes())`, than `islice(primes(), 10)`.

Re:Infinite work is less work by ugexe on Thursday July 11, 2019 @02:55PM (#20414339)
perl6 -e 'my $integers := gather for 0..Inf { take $_ }; say $integers[2]'
Re:Infinite work is less work by kccqzy on Friday July 12, 2019 @12:27AM (#20418155)
There's no memoization in that approach however.