[Haskell-beginners] Query regarding an unusually behaving code
akaberto at gmail.com
Fri Nov 13 06:47:33 UTC 2015
This is because the second let redefines your first definition. Hence, you
don't have a base case anymore.
digs 0 =
digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
When I compile this with ghc though, it works fine.
This is how ghci works, I'd presume.
On Fri, Nov 13, 2015 at 12:06 PM, Abhishek Kumar <abhishekkmr18 at gmail.com>
> 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.
> let digs 0 =
> let digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
> digs 100
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners