From: "William D. Neumann" <wneumann@cs.unm.edu>
To: Lucas Holland <hollandlucas@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Factorial function
Date: Tue, 23 Jan 2007 12:26:43 -0700 (MST) [thread overview]
Message-ID: <Pine.LNX.4.62.0701231223020.13408@io.cs.unm.edu> (raw)
In-Reply-To: <8C584854-A0BC-4926-A4E7-60620DF4D995@gmail.com>
On Tue, 23 Jan 2007, Lucas Holland wrote:
> Hi, why does this function:
>
> let rec fact n =
> n * fact (n-1);;
>
> yield an overflow error if called with n = 5?
It overflows because you don't provide a base case for the recursion (e.g.
if n = 1 then 1 else ...), it simply cycles backwards through the ints
until the stack is exhausted.
Also, if you're just learning OCaml, you may want to use the Caml
Beginners list for these types of questions. You con find the list
information at: http://groups.yahoo.com/group/ocaml_beginners
William D. Neumann
---
"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Life is unfair. Kill yourself or get over it.
-- Black Box Recorder
next prev parent reply other threads:[~2007-01-23 19:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-23 18:53 Lucas Holland
2007-01-23 18:59 ` [Caml-list] " Steve Taylor
2007-01-23 19:26 ` William D. Neumann [this message]
2007-01-23 20:12 ` Jonathan Roewen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.62.0701231223020.13408@io.cs.unm.edu \
--to=wneumann@cs.unm.edu \
--cc=caml-list@inria.fr \
--cc=hollandlucas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox