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. Re:  why doesn't this work? (David McBride)
   2. Re:  Beginners Digest, Vol 139, Issue 2 (Alex Zarebski)


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

Message: 1
Date: Thu, 9 Jan 2020 08:47:07 -0500
From: David McBride <toa...@gmail.com>
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] why doesn't this work?
Message-ID:
        <can+tr40ygpy98nxydxze6v_jdcls8svj7pswyxo2n93nchc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Floating point comparisons are a bad idea.

A better way would be x `mod` y == 0.

On Wed, Jan 8, 2020 at 10:01 AM Alexander Chen <alexan...@chenjia.nl> wrote:

> hi,
>
> for a List comprehension I want to only include the integers of a
> division. In my beginners mind this should work:
>
> (round (x / y)) == (x / y)
>
> however, i get a nontrivial error blurp.
>
> what am i doing wrong?
>
> best,
>
> Alexander
>
>
>
> _______________________________________________
> 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/20200109/a089b317/attachment-0001.html>

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

Message: 2
Date: Thu, 9 Jan 2020 23:51:29 +0000
From: Alex Zarebski <aezareb...@gmail.com>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 139, Issue 2
Message-ID:
        <CAKsw2nGMznzjfMQS66idE53zuatnDbbm=ygzrvalyspjvl7...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

If the goal is to filter a list for numbers which are multiples of some
other number, perhaps the =mod= function would be a neater way to do this.

It is part of the Prelude with documentation here:
https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#v:mod

On Thu, Jan 9, 2020 at 12:01 PM <beginners-requ...@haskell.org> wrote:

> 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.  why doesn't this work? (Alexander Chen)
>    2. Re:  why doesn't this work? (Oliver Charles)
>    3. Re:  why doesn't this work? (Ut Primum)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 8 Jan 2020 16:01:20 +0100 (CET)
> From: Alexander Chen <alexan...@chenjia.nl>
> To: beginners@haskell.org
> Subject: [Haskell-beginners] why doesn't this work?
> Message-ID: <675050120.318296.1578495680...@ichabod.co-bxl>
> Content-Type: text/plain; charset="utf-8"
>
> hi,
>
> for a List comprehension I want to only include the integers of a
> division. In my beginners mind this should work:
>
> (round (x / y)) == (x / y)
>
> however, i get a nontrivial error blurp.
>
> what am i doing wrong?
>
> best,
>
> Alexander
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20200108/90275f59/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Wed, 08 Jan 2020 16:37:47 +0000
> From: "Oliver Charles" <ol...@ocharles.org.uk>
> To: beginners@haskell.org
> Subject: Re: [Haskell-beginners] why doesn't this work?
> Message-ID: <ef1efd77-6d1c-4a07-94d5-d5125947d...@www.fastmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On Wed, 8 Jan 2020, at 3:01 PM, Alexander Chen wrote:
> > hi,
> >
> > for a List comprehension I want to only include the integers of a
> division. In my beginners mind this should work:
> >
> > (round (x / y)) == (x / y)
> >
> > however, i get a nontrivial error blurp.
>
> Could you share what the "nontrivial error blurp" is? It will be easier
> for people to reply to you if they can see the problem without
> having to reproduce it manually.
>
> Ollie
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20200108/57c13db7/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Wed, 8 Jan 2020 18:50:35 +0100
> From: Ut Primum <utpri...@gmail.com>
> 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] why doesn't this work?
> Message-ID:
>         <
> canjdmkjmrajergqere4cr0gmasqh2dnh36pw4hvw_ekdu3c...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
> I think the problem is in the types.
> If you look at the type of the function round, you can see its result is an
> Integral:
>
> >> :t round
> round :: (Integral b, RealFrac a) => a -> b
>
> The result of the division x/y, instead, is a Fractional, and you cannot
> test equality between two things of different types.
> To solve the problem you can do a type cast, by converting the Integral to
> a Num, using fromInteger:
>
> (fromInteger (round (x/y))) == (x/y)
>
> This should work.
>
> Cheers,
> Ut
>
>
>
>
> Il giorno mer 8 gen 2020 alle ore 16:01 Alexander Chen <
> alexan...@chenjia.nl>
> ha scritto:
>
> > hi,
> >
> > for a List comprehension I want to only include the integers of a
> > division. In my beginners mind this should work:
> >
> > (round (x / y)) == (x / y)
> >
> > however, i get a nontrivial error blurp.
> >
> > what am i doing wrong?
> >
> > best,
> >
> > Alexander
> >
> >
> >
> > _______________________________________________
> > 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/20200108/4efa2af4/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 139, Issue 2
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200109/90398f40/attachment-0001.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 139, Issue 3
*****************************************

Reply via email to