Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jocelyn Serot <Jocelyn.Serot@lasmea.univ-bpclermont.fr>
To: caml-list@margaux.inria.fr
Subject: curried fns
Date: Mon, 20 Nov 1995 16:54:06 MET	[thread overview]
Message-ID: <199511201556.QAA15838@concorde.inria.fr> (raw)


Hello,

Could someone please explain the difference(s) between:

	let f x = function y -> y + x;;

and

	let f x y = y + x;;

Both have the same type (int -> int -> int) but they seem to behave
distinctly wrt evaluation strategy.

For instance, if i use the 1st form and write:

	let h x = let z = fact x in fun y -> y + z;;
	map (h 30) [1;2;3];; (* note 1 *)

fact 30 gets evaluated only once (partial evaluation), while
the use of the 2nd form for the h function:

	let h x y = let z = fact x in y + z;;
	map (h 30) [1;2;3];;
 
causes fact 30 to be evaluated _for each_ element of the list.

Is this normal or do i misunderstand sth about curryfied fns ?..

Thanks for any help

	Jocelyn S.

(* note 1: this example is inspired from a a similar one given by
   X. Leroy in his Research Report INRIA/117 about the Zinc experiment *)

--
E-mail: Jocelyn.Serot@lasmea.univ-bpclermont.fr
S-mail: LASMEA - URA 1793 CNRS, Universite Blaise Pascal, 63177 Aubiere cedex
Tel: (33) 73.40.73.30 - Fax: (33) 73.40.72.62




             reply	other threads:[~1995-11-20 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-11-20 15:54 Jocelyn Serot [this message]
1995-11-20 18:06 ` John Harrison
1995-11-21 10:48   ` Pierre Weis
1995-11-20 18:51 Laurent CHENO
1995-11-20 20:32 Fauque UPS
1995-11-21  5:17 Tarizzo Martial

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=199511201556.QAA15838@concorde.inria.fr \
    --to=jocelyn.serot@lasmea.univ-bpclermont.fr \
    --cc=caml-list@margaux.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