From: Martin Weber Date: 2003-08-26T00:45:25+09:00 Subject: Re: Rite/Ruby2.0 & Ruby vs OCaml On Tue, Aug 26, 2003 at 12:10:21AM +0900, Brian Candler wrote: > On Mon, Aug 25, 2003 at 02:23:56PM +0900, Jason Watkins wrote: > > OCaml is a fine language, but it certainly is not as fun as ruby... unless > > you're a functional languages geek :P. > > I'm not sure that even functional languages geeks would approve of OCaml. I > just installed it and tried writing: > > let rec sum n = > if n < 1 then 0 else n + sum(n-1);; > > print_int(sum 1000000);; let sum n = let rec aux n acc = if n < 1 then acc else aux (n-1) (acc+n) in aux n 0;; print_int(sum 100);; Note: native ints are native ints in Ocaml. For sum 1000000 you'll want to use the bignum lib. > and all I got was: > > Stack overflow during evaluation (looping recursion?). > > So unless I've missed something, it doesn't seem to support tail-recursion, Your function isn't tail-recursive (it needs the n when returning). > in which case functional programmers aren't going to be happy at all... Not only functional programmers are happy with ocaml :) Regards, -Martin