u/Critical_Pin4801in r/haskell • Recommends
I'm feeling betrayed!!!! ;_;
So I have some time off and I'm relearning Haskell, and part of the charm was coming back to cute recursive, lazy, infinite definitions like this:
fibSequence :: Integer
fibSequence = 0 : 1 : zipWith (+) fibSequence (tail fibSequence)
which is a pretty good way to define the Fibonacci sequence.
And then I was looking around and watching this video, which is really fun, which gives
primeSequence :: Integer
primeSequence = sieveOfEratosthenes 2..
sieveOfEratosthenes :: Integer -> Integer
sieveOfEratosthenes (p:ps) = p : sieveOfEratosthenes x | x <- ps, x `mod` p /= 0
And I was like OMG GENIUS! Nice. And then late…