Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
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 <[email protected]>
Subject: [Haskell-beginners] Sub-second precision
To: beginners <[email protected]>
Message-ID:
<[email protected]>
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 <[email protected]>
Subject: [Haskell-beginners] proper way to read fold types
To: haskellbeginners <[email protected]>
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 <[email protected]>
Subject: Re: [Haskell-beginners] proper way to read fold types
To: [email protected]
Cc: prad <[email protected]>
Message-ID: <[email protected]>
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 <[email protected]>
Subject: [Haskell-beginners] Re: proper way to read fold types
To: [email protected]
Message-ID: <20100724223150.2e03d...@gom>
Content-Type: text/plain; charset=US-ASCII
On Sun, 25 Jul 2010 00:15:24 +0200
Daniel Fischer <[email protected]> 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" <[email protected]>
Subject: Re: [Haskell-beginners] Sub-second precision
To: beginners <[email protected]>, "Alex Rozenshteyn"
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Sat, 24 Jul 2010 22:09:15 +0200, Alex Rozenshteyn
<[email protected]> 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
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 25, Issue 50
*****************************************