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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thomas Fischbacher <Thomas.Fischbacher@P...>
Subject: Re: fancy types (was Re: [Caml-list] ocaml killer)

On Thu, 29 Jan 2004, William Lovas wrote:

>     # type ('a, 'b) specialist = S of (('a, 'b) specialist -> 'a -> 'b);;
>     type ('a, 'b) specialist = S of (('a, 'b) specialist -> 'a -> 'b)
>     # let fac n =
>         let do_rec (S specialist) n =
>           if n = 0 then
>             1
>           else
>             n * specialist (S specialist) n
>         in
>         do_rec (S do_rec) n;;
>     val fac : int -> int = <fun>

Hm, correct me if I am wrong, but to me this looks as if you had to 
unnecessarily cons at every recursive call...

-- 
regards,               tf@cip.physik.uni-muenchen.de              (o_
 Thomas Fischbacher -  http://www.cip.physik.uni-muenchen.de/~tf  //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y)           V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1))                  (Debian GNU)

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