Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] optional arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] optional arguments
On Mon, Nov 17, 2003 at 11:52:49AM +0300, Selentek 24331-03 wrote:
[...]

Like this?

# let f ?v () =
  match v with
  | Some i -> i + 1
  | None   -> 0      ;;
val f : ?v:int -> unit -> int = <fun>

# let v = Some 1;;
val v : int option = Some 1

# f ?v ();;
- : int = 2

# let v = None;;
val v : 'a option = None

# f ?v ();;
- : int = 0

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners