<div dir="ltr"><div><div><div>This is because the second let redefines your first definition.  Hence, you don't have  a base case anymore.<br><br></div>digs 0 =[]<br>digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]<br><br></div>When I compile this with ghc though, it works fine.  <br><br></div>This is how ghci works, I'd presume.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 13, 2015 at 12:06 PM, 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"><div dir="ltr"><span><span>Bellow is my code for returning a list of digits given an integer.I'm unable to find any bug in it but somehow it crashes any computer I run it on when I try to calculate digs 100.Please tell me bug in my code.<br></span></span><div><span><span><br>let digs 0 =[0]
<br>let digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
<br>digs 100<br><br></span></span></div><div><span><span>Thanks<span class="HOEnZb"><font color="#888888"><br></font></span></span></span></div><span class="HOEnZb"><font color="#888888"><div><span><span>Abhishek<br></span></span></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></div>