News for hackers. Stuff that matters.
Re:Infinite work is less work by piinbinary on Thursday July 11, 2019 @05:59PM (#20416288)
Just because I can't resist writing little math things in Haskell:

    primes = 2 : filter isPrime [3..]

    isPrime n =
      let divisors = takeWhile (\d -> d * d <= n) primes
      in not $ any (\d -> n `mod` d == 0) divisors

    strongPrimes =
      let primeTriples = zip3 primes (drop 1 primes) (drop 2 primes)
      in [b | (a, b, c) <- primeTriples, b*2 > a + c]
Re:Infinite work is less work by kdmccormick on Thursday July 11, 2019 @06:22PM (#20416429)
Proof that you can write something elegant in Haskell and use comprehensible variable names.
Re:Infinite work is less work by moomin on Friday July 12, 2019 @08:41AM (#20420236)
I like the zip3, I should have thought of that. I think I prefer the mapMaybe, but then I avoid list comprehensions.