caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Optional arguments
@ 2008-11-09 19:17 malc
  2008-11-09 19:51 ` [Caml-list] " David Teller
  0 siblings, 1 reply; 8+ messages in thread
From: malc @ 2008-11-09 19:17 UTC (permalink / raw)
  To: caml-list

         Objective Caml version 3.10.0

# let a i = let b ?(i=i mod 3) () = i in b ~i ();;
val a : int -> int = <fun>
# for i = 0 to 5 do print_int (a i); done;;
012345- : unit = ()

Is this something to be expected? Or perhaps something which calls
for an upgrade?

-- 
mailto:av1474@comtv.ru


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [Caml-list] optional arguments
@ 2003-11-17  8:52 Selentek 24331-03
  2003-11-17 10:13 ` Richard Jones
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Selentek 24331-03 @ 2003-11-17  8:52 UTC (permalink / raw)
  To: caml-list

Hello,

Is there any way to "send optional argument with None value".
for example:

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

let f ?v () =
  match v with
  | Some i -> i + 1
  | None   -> 0

.

First solution:

match a with
| Some i -> f ~v:i ()
| None   -> f ()

Can I find something more easy with out redifinition of the function ?
something like: f a (), but funtion defined by ``let f ?v'' and ``a'' is int option.


Thanks.

Sorry for my english.
-- 

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-10 20:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-09 19:17 Optional arguments malc
2008-11-09 19:51 ` [Caml-list] " David Teller
2008-11-10 20:52   ` malc
  -- strict thread matches above, loose matches on Subject: below --
2003-11-17  8:52 [Caml-list] optional arguments Selentek 24331-03
2003-11-17 10:13 ` Richard Jones
2003-11-17 10:44   ` Selentek 24331-03
2003-11-17 10:13 ` Artem Prisyznuk
2003-11-17 17:24 ` Brian Hurt

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