Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Jean Krivine" <jean.krivine@gmail.com>
To: "circ ular" <circularfunc@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Difference between "let rec" and just "let"?
Date: Wed, 13 Aug 2008 09:52:43 -0400	[thread overview]
Message-ID: <dc2907b70808130652u70a9b3e9r4784c506f360b5f8@mail.gmail.com> (raw)
In-Reply-To: <d5f6b0140808130549m195f1247t7ecb00649d95d0bf@mail.gmail.com>

Each time you use let, you can also use let rec, but you have to use
the rec (for recursive) if you want to declare a recursive function as
in:
let rec f x = if x<0 then 0 else x * f(x-1)


On Wed, Aug 13, 2008 at 8:49 AM, circ ular <circularfunc@gmail.com> wrote:
> what is the difference between "let rec" and just "let"? what does rec
> stand for?
>
> are the following defintions exactly the same? at least they seem to
> give the same results...
>
> # let rec cube x = x*x*x;;
> val cube : int -> int = <fun>
> # cube 12;;
> - : int = 1728
>
> # let cubex x = x*x*x;;
> val cubex : int -> int = <fun>
> # cubex 12;;
> - : int = 1728
> #
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  reply	other threads:[~2008-08-13 13:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13 12:49 circ ular
2008-08-13 13:52 ` Jean Krivine [this message]
2008-08-13 18:39   ` [Caml-list] " Andrej Bauer
2008-08-13 15:17 ` Christophe TROESTLER

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=dc2907b70808130652u70a9b3e9r4784c506f360b5f8@mail.gmail.com \
    --to=jean.krivine@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=circularfunc@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