caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yves Bertot <Yves.Bertot@sophia.inria.fr>
To: Damien Guichard <alphablock@orange.fr>
Cc: "caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Error: This function is applied to too many	arguments,maybe you forgot a `; '
Date: Mon, 04 Aug 2008 07:58:03 +0200	[thread overview]
Message-ID: <48969A6B.5010005@sophia.inria.fr> (raw)
In-Reply-To: <20080804005824.5FA4480000A0@mwinf2804.orange.fr>


To be more precise, Ocaml being a functional language, any function, 
when applied
to one argument, may return a new function which can in turn be applied 
to another
argument.

Thus if you write :

(a (b)) (c),

Ocaml (and most other functional programming languages), understand that

a(b) is supposed to be a function, that returns another function, then 
applied to c.

In practice, this trick is used extensively throughout functional 
programs, so
that placing parentheses around arguments would result in a humongous number
of parentheses.  For this reason, a new convention for parentheses was 
enforced:
you don't put any parentheses around function arguments, unless it is 
necessary
for disambiguation (for instance, if you want b to be applied to c, and 
you don't
place parentheses around the function part, so that (a(b))(c) is simply 
written

a b c

This means : a applied to b, and then to c,

Now, if you want "a applied to the result of applying b to c", you write

a (b c)

Please note there are no parentheses around c.

In practice, most functions taking several arguments are described in this
manner, instead of being described as function taking a pair as argument.
This is known as "currification" because Curry was one of the early 
mathematicians
to advocate the idea that mathematics (and programming) could be described
with only one-argument functions.

In your case, both print_int and fac are one argument functions, as can 
be seen from
their type.

Yves


  reply	other threads:[~2008-08-04  5:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-04  1:00 Damien Guichard
2008-08-04  5:58 ` Yves Bertot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-08-04  0:46 Error: This function is applied to too many arguments, maybe you forgot a `;' Ben Aurel
2008-08-05 12:11 ` [Caml-list] Error: This function is applied to too many arguments, maybe you forgot a `; ' Richard Jones
2008-08-05 13:29   ` Peng Zang

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=48969A6B.5010005@sophia.inria.fr \
    --to=yves.bertot@sophia.inria.fr \
    --cc=alphablock@orange.fr \
    --cc=caml-list@yquem.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).