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. Simple Moving Average of a list of real numbers (Alexandr M)
2. Re: 'read' throws; why not maybe or either? (Michael Orlitzky)
3. Re: Simple Moving Average of a list of real numbers
(Chadda? Fouch?)
4. Re: Simple Moving Average of a list of real numbers (yi lu)
5. Re: Simple Moving Average of a list of real numbers
(Patrick Redmond)
6. Re: 'read' throws; why not maybe or either? (Patrick Redmond)
----------------------------------------------------------------------
Message: 1
Date: Mon, 25 Nov 2013 17:28:32 +0200
From: Alexandr M <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Simple Moving Average of a list of real
numbers
Message-ID:
<CAJ4nbUoWHYVPQ5TLtRANcuwj1ZD=p-1X=rhgonv3t4vb-0c...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello !
Could anybody explain me how to calculate simple moving average of a list ?
I have found several examples in internet but I completely don't understand
how it works.
Basically it's necessary to iterate over the list of real numbers and
calculate average values over last n items in the list.
I just can't imagine how to do it without loops.
--
Best regards,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131125/fe54fb15/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 25 Nov 2013 11:37:43 -0500
From: Michael Orlitzky <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] 'read' throws; why not maybe or
either?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 11/24/2013 04:49 PM, Patrick Redmond wrote:
> Is there a variation of 'read' which uses Maybe or Either to handle
> failure instead of an exception?
readMaybe:
http://hackage.haskell.org/package/base-4.6.0.1/docs/Text-Read.html#v:readMaybe
Prelude> import Text.Read (readMaybe)
Prelude Text.Read> readMaybe "Hello, World!" :: Maybe Int
Nothing
Prelude Text.Read> readMaybe "45" :: Maybe Int
Just 45
------------------------------
Message: 3
Date: Mon, 25 Nov 2013 19:33:51 +0100
From: Chadda? Fouch? <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Moving Average of a list of
real numbers
Message-ID:
<canfjzrb-ui5bajc2fe1fkgo-wgf5vane-gx6dmpr6oo6bxc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Mon, Nov 25, 2013 at 4:28 PM, Alexandr M <[email protected]> wrote:
> Hello !
>
> Could anybody explain me how to calculate simple moving average of a list ?
>
> I have found several examples in internet but I completely don't
> understand how it works.
>
> Basically it's necessary to iterate over the list of real numbers and
> calculate average values over last n items in the list.
>
> I just can't imagine how to do it without loops.
>
Who needs loops when you have recursion, or more to the point good
combinators ! You can do it in a few lines using only splitAt, length (to
check the result of splitAt), zip, and scanl. (and sum, +, - and /, of
course).
Ask again, if that's not enough.
--
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131125/2cf10165/attachment-0001.html>
------------------------------
Message: 4
Date: Tue, 26 Nov 2013 09:50:58 +0800
From: yi lu <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Moving Average of a list of
real numbers
Message-ID:
<cakcmqqyj72qxcakm6x_ejrpcw0yrovtcnpysoyrauqpaypr...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
It reminds me of k-means.
On Tue, Nov 26, 2013 at 2:33 AM, Chadda? Fouch? <[email protected]>wrote:
> On Mon, Nov 25, 2013 at 4:28 PM, Alexandr M <[email protected]> wrote:
>
>> Hello !
>>
>> Could anybody explain me how to calculate simple moving average of a list
>> ?
>>
>> I have found several examples in internet but I completely don't
>> understand how it works.
>>
>> Basically it's necessary to iterate over the list of real numbers and
>> calculate average values over last n items in the list.
>>
>> I just can't imagine how to do it without loops.
>>
>
> Who needs loops when you have recursion, or more to the point good
> combinators ! You can do it in a few lines using only splitAt, length (to
> check the result of splitAt), zip, and scanl. (and sum, +, - and /, of
> course).
>
> Ask again, if that's not enough.
>
> --
> Jeda?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131126/57a9fa8b/attachment-0001.html>
------------------------------
Message: 5
Date: Tue, 26 Nov 2013 17:31:22 +1300
From: Patrick Redmond <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Moving Average of a list of
real numbers
Message-ID:
<cahuea4ganxiw-qvokdfkmf-9xxqo6lb0o-9rpduvddsny6g...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
In functional programming, loops are implemented using recursion and tailcalls.
You have the power of loops beyond what "for" and "while" can express.
On Tuesday, November 26, 2013, Alexandr M wrote:
> Hello !
>
> Could anybody explain me how to calculate simple moving average of a list ?
>
> I have found several examples in internet but I completely don't
> understand how it works.
>
> Basically it's necessary to iterate over the list of real numbers and
> calculate average values over last n items in the list.
>
> I just can't imagine how to do it without loops.
>
> --
> Best regards,
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131126/ea22c2e6/attachment-0001.html>
------------------------------
Message: 6
Date: Tue, 26 Nov 2013 17:32:32 +1300
From: Patrick Redmond <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] 'read' throws; why not maybe or
either?
Message-ID:
<CAHUea4H6=3d2hyeehapzpyqon3-jcp_53xy_p9re2r_x9vx...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Thanks all! I was able to make use of readEither to do just what I wanted.
On Tuesday, November 26, 2013, Michael Orlitzky wrote:
> On 11/24/2013 04:49 PM, Patrick Redmond wrote:
> > Is there a variation of 'read' which uses Maybe or Either to handle
> > failure instead of an exception?
>
> readMaybe:
>
>
> http://hackage.haskell.org/package/base-4.6.0.1/docs/Text-Read.html#v:readMaybe
>
> Prelude> import Text.Read (readMaybe)
> Prelude Text.Read> readMaybe "Hello, World!" :: Maybe Int
> Nothing
> Prelude Text.Read> readMaybe "45" :: Maybe Int
> Just 45
>
> _______________________________________________
> Beginners mailing list
> [email protected] <javascript:;>
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131126/348022af/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 65, Issue 10
*****************************************