Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  list doesn't end (Alexander Chen)
   2. Re:  list doesn't end (Oliver Charles)
   3. Re:  list doesn't end (Francesco Ariis)


----------------------------------------------------------------------

Message: 1
Date: Sat, 23 Nov 2019 19:38:03 +0100 (CET)
From: Alexander Chen <alexan...@chenjia.nl>
To: beginners@haskell.org
Subject: [Haskell-beginners] list doesn't end
Message-ID: <1722033790.317238.1574534283...@ichabod.co-bxl>
Content-Type: text/plain; charset="utf-8"

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

this 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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20191123/77520139/attachment-0001.html>

------------------------------

Message: 2
Date: Sat, 23 Nov 2019 18:42:05 +0000
From: Oliver Charles <ol...@ocharles.org.uk>
To: Alexander Chen <alexan...@chenjia.nl>,  The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] list doesn't end
Message-ID:
        <CAGRp5Rk0RwSe39n8zx+=tm61qrvwtzvgshps5fgwgft3lvk...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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, <alexan...@chenjia.nl> 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
>
> this 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
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20191123/151c94ae/attachment-0001.html>

------------------------------

Message: 3
Date: Sat, 23 Nov 2019 20:05:32 +0100
From: Francesco Ariis <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] list doesn't end
Message-ID: <20191123190532.ga...@x60s.casa>
Content-Type: text/plain; charset=utf-8

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


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 137, Issue 10
******************************************

Reply via email to