Compiling below code (ghc --make) still doesn't gives result on my i3 Ubuntu 64bit machine.Can u please elaborate optimisations you did?<div>Thanks</div><div>Abhishek<br><br>On Friday, December 11, 2015, Kim-Ee Yeoh <<a href="mailto:ky3@atamo.com">ky3@atamo.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Have you tried BangPatterns? Compiled with optimization, I get 22 secs. Here's the full program:<br><br><span style="font-family:monospace,monospace">{-# LANGUAGE BangPatterns #-}<br><br>f :: Int -> Int -> Int<br>f !m !n <br> | m==0 = n+1<br> | n==0 = f (m-1) 1<br> | otherwise = f (m-1) (f m (n-1))<br><br>main = putStrLn (show (f 4 1))<br></span><br></div><div class="gmail_extra"><br clear="all"><div><div>-- Kim-Ee</div></div>
<br><div class="gmail_quote">On Fri, Dec 11, 2015 at 9:47 PM, Abhishek Kumar <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','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><font color="#888888"><div>Abhishek Kumar</div></font></span></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="javascript:_e(%7B%7D,'cvml','Beginners@haskell.org');" target="_blank">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></div>
</blockquote></div>