<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 25, 2013 at 4:28 PM, Alexandr M <span dir="ltr"><<a href="mailto:rus314@gmail.com" target="_blank">rus314@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello !<div><br></div><div>Could anybody explain me how to calculate simple moving average of a list ?</div><div><br></div><div>I have found several examples in internet but I completely don't understand how it works.</div>

<div><br></div><div>Basically it's necessary to iterate over the list of real numbers and calculate average values over last n items in the list.</div><div><br></div><div>I just can't imagine how to do it without loops.</div>
</div></blockquote><div><br></div><div>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).</div>
<div><br></div><div>Ask again, if that's not enough.</div><div><br></div><div>-- </div><div>Jedaï </div></div></div></div>