[Haskell-beginners] Haskell code optimisation

Sumit Sahrawat, Maths & Computing, IIT (BHU) sumit.sahrawat.apm13 at iitbhu.ac.in
Fri Dec 11 15:17:12 UTC 2015


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.
Folds were the first stumbling point for me when learning Haskell, and this
paper helped me a lot.

On 11 December 2015 at 20:17, Abhishek Kumar <abhishekkmr18 at gmail.com>
wrote:

> 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.
>
> ------haskell code
> f m n  | m==0 =n+1
>            | n==0 = f  (m-1) 1
>            | otherwise = f (m-1) (f m (n-1))
>
> Thanks
> Abhishek Kumar
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Sumit Sahrawat,

Junior - Mathematics and Computing,
Indian Institute of Technology - BHU,
Varanasi, India
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151211/c8c7103b/attachment.html>


More information about the Beginners mailing list