Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/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. Sub-second precision (Alex Rozenshteyn) 2. proper way to read fold types (prad) 3. Re: proper way to read fold types (Daniel Fischer) 4. Re: proper way to read fold types (prad) 5. Re: Sub-second precision (Henk-Jan van Tuyl) ---------------------------------------------------------------------- Message: 1 Date: Sat, 24 Jul 2010 23:09:15 +0300 From: Alex Rozenshteyn <rpglove...@gmail.com> Subject: [Haskell-beginners] Sub-second precision To: beginners <beginners@haskell.org> Message-ID: <aanlkti=4+cffb63+qv3sgydtzphjcu=ikcgstoazc...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I'm trying to write a simple timer application (mostly to learn gui programming), and I'd like it to display 1/100ths of a second. I know I can fake this with threadDelay, but I was wondering if there's a way to get current time to more precision than one second. -- Alex R -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20100724/037aceb8/attachment-0001.html ------------------------------ Message: 2 Date: Sat, 24 Jul 2010 14:50:42 -0700 From: prad <p...@towardsfreedom.com> Subject: [Haskell-beginners] proper way to read fold types To: haskellbeginners <beginners@haskell.org> Message-ID: <20100724145042.6dcd0...@gom> Content-Type: text/plain; charset=US-ASCII here are the descriptions for foldr and foldr1 foldr :: (a -> b -> b) -> b -> [a] -> b foldr1 :: (a -> a -> a) -> [a] -> a i'm trying to make sense of the a vs b in foldr, so here goes: foldr takes 3 arguments: 1. some function f, illustrated within () of type b 2. some value of type b 3. some list with elements of type a foldr applies f to each element of [a], computing a new function (f a) which is then applied to the item of type b, computing a result of type b, which is then combined with #2 (this would be the accumulator) finally, the net computation of foldr results in some item of type b. foldr1 takes 2 arguments: 1. some function g, illustrated within () of type a 2. some list with elements of type a foldr1 applies g to each element of [a], computing a new function (g a) which is then applied to a non-explicitly defined item of type a, computing a result also of type a. the net computation of foldr1 results in some item of type a. i know how i can use the folds in some situations, but explaining their type definitions to reveal how they work, is coming out pretty convoluted when i make the attempt. :( -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's ------------------------------ Message: 3 Date: Sun, 25 Jul 2010 00:15:24 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] proper way to read fold types To: beginners@haskell.org Cc: prad <p...@towardsfreedom.com> Message-ID: <201007250015.24282.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="iso-8859-1" On Saturday 24 July 2010 23:50:42, prad wrote: > i know how i can use the folds in some situations, but explaining their > type definitions to reveal how they work, is coming out pretty > convoluted when i make the attempt. :( Maybe this helps: foldr op z [x1, x2, x3] = x1 `op` (x2 `op` (x3 `op` z)) foldr1 op [x1, x2, x3] = x1 `op` (x2 `op` x3) ------------------------------ Message: 4 Date: Sat, 24 Jul 2010 22:31:50 -0700 From: prad <p...@towardsfreedom.com> Subject: [Haskell-beginners] Re: proper way to read fold types To: beginners@haskell.org Message-ID: <20100724223150.2e03d...@gom> Content-Type: text/plain; charset=US-ASCII On Sun, 25 Jul 2010 00:15:24 +0200 Daniel Fischer <daniel.is.fisc...@web.de> wrote: > Maybe this helps: > > foldr op z [x1, x2, x3] = x1 `op` (x2 `op` (x3 `op` z)) > > foldr1 op [x1, x2, x3] = x1 `op` (x2 `op` x3) > thx daniel. the above seems to be the idea of replacing (:) with the function as illustrated in the Another approach on the wiki: http://www.haskell.org/haskellwiki/Fold possibly, i'm making too big a deal trying to say it all in words. i understand what it is doing and how to use it (for the most part) as well as the 'Another approach' illustration. possibly i should just stick to that. -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's ------------------------------ Message: 5 Date: Sun, 25 Jul 2010 18:30:09 +0200 From: "Henk-Jan van Tuyl" <hjgt...@chello.nl> Subject: Re: [Haskell-beginners] Sub-second precision To: beginners <beginners@haskell.org>, "Alex Rozenshteyn" <rpglove...@gmail.com> Message-ID: <op.vgeqsjvvpz0...@zen5.router.home> Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes On Sat, 24 Jul 2010 22:09:15 +0200, Alex Rozenshteyn <rpglove...@gmail.com> wrote: > I'm trying to write a simple timer application (mostly to learn gui > programming), and I'd like it to display 1/100ths of a second. I know I > can > fake this with threadDelay, but I was wondering if there's a way to get > current time to more precision than one second. > That depends on the type of GUI you are using, of course. If you use wxHaskell, you can do it like this: > t <- timer f [ interval := 10 > , on command := repaint > ] where f is the frame handle; you don't need to use t anywhere. The interval is defined in milliseconds. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 25, Issue 50 *****************************************