Browse thread
[Caml-list] ocaml killer
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-01-29 (18:33) |
From: | Alex Baretta <alex@b...> |
Subject: | Re: fancy types (was Re: [Caml-list] ocaml killer) |
Thomas Fischbacher wrote: > On Thu, 29 Jan 2004, William Lovas wrote: > # let fac n = let do_rec specialist n = if n = 0 then 1 else n * specialist specialist (n-1) in do_rec do_rec n;; > > Characters 74-84: > let fac n = let do_rec specialist n = if n = 0 then 1 else n * > specialist specialist (n-1) in do_rec do_rec n;; > > ^^^^^^^^^^ > This expression has type 'a -> 'b -> 'c but is here used with type 'a > > # let fac n = let do_rec specialist n = if n = 0 then 1 else n * (Obj.magic specialist) specialist (n-1) in do_rec do_rec n;; > val fac : int -> int = <fun> > > # fac 8;; > - : int = 40320 As far as I can see you are asking for no more than recursive types. [alex@alex graph]$ ocaml -rectypes Objective Caml version 3.07+2 # let fac n = let do_rec specialist n = if n = 0 then 1 else n * specialist specialist (n-1) in do_rec do_rec n;; val fac : int -> int = <fun> # fac 3;; - : int = 6 This is kind of thread where an RTFL comment might be appropriate. Alex ------------------- 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