<div dir="ltr">Graham Hutton's paper "A tutorial on the expressiveness and universality of folds", provides a good introduction to folds, and implements the Ackerman function as an example.<div>Folds were the first stumbling point for me when learning Haskell, and this paper helped me a lot.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 December 2015 at 20:17, Abhishek Kumar <span dir="ltr"><<a href="mailto:abhishekkmr18@gmail.com" target="_blank">abhishekkmr18@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I was trying to write below program for ackerman function but it fails (waits too long) for ack(4,1) whereas a recursive C program gives result in 37secs.Can someone pls explain this behaviour and recomend some optimisation.<div><div><br></div><div>------haskell code</div><div>f m n | m==0 =n+1</div><div> | n==0 = f (m-1) 1</div><div> | otherwise = f (m-1) (f m (n-1))</div><div><br></div><div>Thanks</div><span class="HOEnZb"><font color="#888888"><div>Abhishek Kumar</div></font></span></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><span style="font-size:12.8px">Sumit Sahrawat,</span></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px">Junior - Mathematics and Computing</span><span style="font-size:12.8px">,</span><br></div><div dir="ltr" style="font-size:12.8px"><div>Indian Institute of Technology - BHU,</div><div>Varanasi, India</div></div></div></div></div></div></div></div>
</div>