<br><font size=2 face="sans-serif">Hello,</font>
<br>
<br><tt><font size=2>&gt; For example, the natural and naive way to write
Andrew's &quot;mean&quot; function<br>
&gt; doesn't involve tuples at all: simply tail recurse with two accumulator<br>
&gt; parameters, and compute the mean at the end. &nbsp;GHC's strictness
analyser<br>
&gt; does the right thing with this, so there's no need for seq, $!, or
the<br>
&gt; like. &nbsp;It's about 3 lines of code.<br>
&gt; </font></tt>
<br><tt><font size=2>Is this the code you mean?</font></tt>
<br>
<br><tt><font size=2>&nbsp; &nbsp; meanNat = go 0 0 where</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; go s n [] = s / n</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; go s n (x:xs) = go (s+x)
(n+1) xs</font></tt>
<br><tt><font size=2><br>
If so, bang patterns are still required bang patterns in ghc-6.8.2 to run
in constant memory:</font></tt>
<br>
<br><tt><font size=2>&nbsp; &nbsp; meanNat = go 0 0 where</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; go s n [] = s / n</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; go !s !n (x:xs) = go (s+x)
(n+1) xs</font></tt>
<br>
<br><tt><font size=2>Is there some other way to write it so that ghc will
essentially insert the bangs for me?</font></tt>
<br>
<br><tt><font size=2>-Jeff</font></tt>
<br>
<br>
<br>
<span style="font-family:'Arial',sans-serif; font-size:8pt; color:#000000">---<br>
<br>
This e-mail may contain confidential and/or privileged information. If you <br>
are not the intended recipient (or have received this e-mail in error) <br>
please notify the sender immediately and destroy this e-mail. Any <br>
unauthorized copying, disclosure or distribution of the material in this <br>
e-mail is strictly forbidden.</span>