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. Mixed division (Lawrence Bottorff) 2. Re: Mixed division (Ut Primum) 3. Re: Mixed division (Lawrence Bottorff) 4. Cabal Build (A. Mc.) 5. Function with mod cases? (Lawrence Bottorff) ---------------------------------------------------------------------- Message: 1 Date: Fri, 5 Feb 2021 12:22:52 -0600 From: Lawrence Bottorff <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Mixed division Message-ID: <CAFAhFSWOpSxs1UK0B-xBSG+gnqECaGg3TU_WE-waShncm=u...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I can divide a float by an integer > 2.4 / 3 0.7999999999999999 but why can I not do this? < 2.4 / (length [1,2,3]) <interactive>:288:1-22: error: * No instance for (Fractional Int) arising from a use of `/' * In the expression: 2.4 / (length [1, 2, 3]) LB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210205/ad817bbb/attachment-0001.html> ------------------------------ Message: 2 Date: Fri, 5 Feb 2021 19:28:51 +0100 From: Ut Primum <utpri...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Mixed division Message-ID: <canjdmklgrnp34k3o78y1uzh04tfjhqwsbtyz02u_z0sapcd...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi, when you write 3 Haskell sees it as a "num" while the type of the length [1,2,3] is "int". So 3 and length [1,2,3] have not the same type. Il ven 5 feb 2021, 19:23 Lawrence Bottorff <borg...@gmail.com> ha scritto: > I can divide a float by an integer > > > 2.4 / 3 > 0.7999999999999999 > > but why can I not do this? > > < 2.4 / (length [1,2,3]) > <interactive>:288:1-22: error: > * No instance for (Fractional Int) arising from a use of `/' > * In the expression: 2.4 / (length [1, 2, 3]) > > LB > _______________________________________________ > 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/20210205/4d96d480/attachment-0001.html> ------------------------------ Message: 3 Date: Fri, 5 Feb 2021 12:36:03 -0600 From: Lawrence Bottorff <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Mixed division Message-ID: <CAFAhFSUOLGkPD4at9vtvvO1=refdovwwrtvmtrpplu6fhd5...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" This works myAvg :: [Float] -> Float myAvg [] = 0.0 myAvg xs = (foldr (+) 0.0 xs) / (fromIntegral (length xs) :: Float) but is there a simpler way to "cast" the value of (length xs)? On Fri, Feb 5, 2021 at 12:29 PM Ut Primum <utpri...@gmail.com> wrote: > Hi, > when you write 3 Haskell sees it as a "num" while the type of the length > [1,2,3] is "int". So 3 and length [1,2,3] have not the same type. > > Il ven 5 feb 2021, 19:23 Lawrence Bottorff <borg...@gmail.com> ha scritto: > >> I can divide a float by an integer >> >> > 2.4 / 3 >> 0.7999999999999999 >> >> but why can I not do this? >> >> < 2.4 / (length [1,2,3]) >> <interactive>:288:1-22: error: >> * No instance for (Fractional Int) arising from a use of `/' >> * In the expression: 2.4 / (length [1, 2, 3]) >> >> LB >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > _______________________________________________ > 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/20210205/11465755/attachment-0001.html> ------------------------------ Message: 4 Date: Fri, 5 Feb 2021 16:42:52 -0800 From: "A. Mc." <47dragonf...@gmail.com> To: beginners@haskell.org Subject: [Haskell-beginners] Cabal Build Message-ID: <CAOsti3=w41oErEdUSvNtGG=Adne9Hkb24M7c7j=neqnafyn...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello, I've been trying to do a cabal build. I'm using Windows 10. But, after going through cabal init, change diretories, run, etc it keeps telling me I don't have permission. My project also has 2 libraries that I wrote for main, and although I tried editing the .cabal file, I'm not sure I have it right. Thanks in advance and thank you for your time. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210205/95f6a282/attachment-0001.html> ------------------------------ Message: 5 Date: Fri, 5 Feb 2021 22:18:31 -0600 From: Lawrence Bottorff <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Function with mod cases? Message-ID: <CAFAhFSV45uiiV7G_SaMTiBkq8fQL=UWKdi=7p4o1i8y+jgw...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I'm looking through *An Introduction to Functional Programming Systems Using Haskell *by Davie and one of the exercises is *Define a function* f *such that* f(x) = x + 3 (mod 5) *Make a version that elaborates cases, as well as a straightforward way.* I'm not really sure what's being asked, so this is what I've come up with myMods xs = map (\x -> (x + 3) `mod` 5) xs > myMods [1..20] [4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3] but when he says *make a version that elaborates cases *I'm not sure what more there is to do. What am I missing? LB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210205/e82cdc45/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 151, Issue 4 *****************************************