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: Selentek 24331-03 <epifanov@k...>
Subject: Re: [Caml-list] optional arguments
YES! Thanks for information.

On 10:13 Mon 17 Nov     , Richard Jones wrote:
> 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/

-- 
Gentoo Linux http://www.gentoo.org

-------------------
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