[Haskell-beginners] Help on first program
Brandon Allbery
allbery.b at gmail.com
Fri Mar 28 23:14:50 UTC 2014
On Fri, Mar 28, 2014 at 7:10 PM, John M. Dlugosz
<ngnr63q02 at sneakemail.com>wrote:
> Each recursive call is either 1 or (n-1) so it should count down 5,4,3,2,1
> and stop the recursion.
>
What am I missing?
It doesn't magically stop at 0; Integer (inferred type) is signed.
Moreover, even if it were not signed, it would wrap around (or possibly
throw an exception on some CPUs, but not on Intel). You need to include a
check for 0 to stop the recursion.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140328/cab4f12c/attachment.html>
More information about the Beginners
mailing list