[Haskell-beginners] list doesn't end

Francesco Ariis fa-ml at ariis.it
Sat Nov 23 19:05:32 UTC 2019


Hello Alexander,

On Sat, Nov 23, 2019 at 07:38:03PM +0100, Alexander Chen wrote:
> Hi,
> 
> I am doing some further learning with euler now in Haskell instead of Julia. But I am getting something strange.
> 
> [x+y+z | x <- a2, y <- b3,  z <- c4, (x+y+z) < 50]
> 
> a2, b3, c4 are all finite lists derived from the lazy list of the primes package. the output is:
> 
> [28,47,33,49

    λ> :m Data.Numbers.Primes
    λ> let a = take 100 primes
    λ> length [x+y+x | x <- a, y <- a, z <- a, (x+y+z) < 50]
    942

I suspect one in [a2, b3, c4] is infinite (or very very long). Can you
paste the whole calculation?
-F


More information about the Beginners mailing list