# list doesn't end Classic List Threaded 7 messages Open this post in threaded view
|

## list doesn't end

 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,49this is not a typo it is still calculating hence the missing bracket (for the last couple of hours, when to a christmas fair in between). The only thing is that, this should be the answer:[28,47,33,49] so it should be done but its not. what am I doing wrong?best,_______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Open this post in threaded view
|

## Re: list doesn't end

 How big are those lists? GHC will not be able to work out x+y+z < 50 will never be true again, it will have to exhaustively consider *every* combination.On Sat, 23 Nov 2019, 6:38 pm Alexander Chen, <[hidden email]> 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,49this is not a typo it is still calculating hence the missing bracket (for the last couple of hours, when to a christmas fair in between). The only thing is that, this should be the answer:[28,47,33,49] so it should be done but its not. what am I doing wrong?best,_______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Open this post in threaded view
|

## Re: list doesn't end

 In reply to this post by Alexander Chen 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 _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Open this post in threaded view
|

## Re: list doesn't end

 Hi Francesco,length a2 = 7072length b3 = 7072length c4 = 82I suspect its the first two that get it into trouble. Is is 7072*7072*82 = 41014081088 permutations, 100*3 = 1000000.So I am guessing that this is not the fix to the euler problem....best.November 23, 2019 8:05:32 PM CET Francesco Ariis <[hidden email]> wrote:">`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 primespackage. 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] 942I suspect one in [a2, b3, c4] is infinite (or very very long). Can youpaste the whole calculation?-F_______________________________________________Beginners mailing list[hidden email]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners`_______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Open this post in threaded view
|

## Re: list doesn't end

 On Sun, Nov 24, 2019 at 05:10:17PM +0100, Alexander Chen wrote: > Hi Francesco, > > length a2 = 7072 > length b3 = 7072 > length c4 = 82 > > I suspect its the first two that get it into trouble. Is is 7072*7072*82 = 41014081088 permutations, 100*3 = 1000000. > > So I am guessing that this is not the fix to the euler problem.... If `x+y+z` need to be <50, and the three are primes, I am puzzled to see such lengths! Which problem is it? _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
 Hi Francesco,Their is a ^2, ^3, ^4 in the lists, respectively.best,November 24, 2019 7:19:51 PM CET Francesco Ariis <[hidden email]> wrote:">`On Sun, Nov 24, 2019 at 05:10:17PM +0100, Alexander Chen wrote:> Hi Francesco,> > length a2 = 7072> length b3 = 7072> length c4 = 82> > I suspect its the first two that get it into trouble. Is is 7072*7072*82 =41014081088 permutations, 100*3 = 1000000.> > So I am guessing that this is not the fix to the euler problem....If `x+y+z` need to be <50, and the three are primes, I am puzzled to seesuch lengths!Which problem is it?_______________________________________________Beginners mailing list[hidden email]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners`_______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners