caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Adam Granicz" <granicz@caltech.edu>
To: <caml-list@inria.fr>
Subject: RE: [Caml-list] currying...
Date: Tue, 6 Mar 2001 02:16:31 -0800	[thread overview]
Message-ID: <IMEJJEAIAKIJJCEKMODGOEEBCCAA.granicz@caltech.edu> (raw)

it does evaluate it partially. you have to remember that functions are
first-class values as well. as a matter of fact, the formally declared
parameters do not really matter, they are resolved by the compiler by
looking at the body of the function. declaring formal parameters is only
necessary when the order of these parameters can not be unambigously
determined. thus

let neg = function
	true -> false
   |  false -> true

is automatically understood as val: neg: bool -> bool.

also, remember that ocaml functions take only one parameter, so

val f: int -> int -> int -> unit

is actually the composition of several functions, the first taking an int
and returning a unit, the second taking an int and returning an int, and so
on.

> so f actually takes two ints, prints them, and then returns a
> function that takes an int and returns unit.  From the val

this one would be

val f: int -> int -> (int -> unit)

anyway, as to your question: if enough arguments are supplied so that the
function can be evaluated, then it is called and returns whatever that
function was supposed to return. however, if not all arguments were given
then the function is only partially evaluated with all known parameters.

let f i j = i+j

f 1 returns a function that expects one argument, so

let g = f 1

and

g 2 return 3.

hope this helps..

adam.

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


             reply	other threads:[~2001-03-06 10:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-06 10:16 Adam Granicz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-03-06  9:39 Chris Hecker
2001-03-06 10:22 ` Thomas Colcombet
2001-03-06 10:33 ` Bruce Hoult
2001-03-06 10:50 ` Remi VANICAT
2001-03-06 16:31 ` Xavier Leroy
2001-03-06 17:41   ` Chris Hecker
2001-03-06 18:43     ` Sven LUTHER
2001-03-06 19:09     ` Marcin 'Qrczak' Kowalczyk
2001-03-06 20:14       ` Chris Hecker
2001-03-06 21:39         ` Marcin 'Qrczak' Kowalczyk
2001-03-06 23:23           ` Chris Hecker
2001-03-06 23:45             ` Marcin 'Qrczak' Kowalczyk
2001-03-07  1:10               ` Chris Hecker
2001-03-07  8:44                 ` Marcin 'Qrczak' Kowalczyk
2001-03-06 23:51             ` Chris Hecker

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=IMEJJEAIAKIJJCEKMODGOEEBCCAA.granicz@caltech.edu \
    --to=granicz@caltech.edu \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).