On Monday 25 Aug 2003 4:10 pm, Brian Candler wrote: > 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);; > > 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, > in which case functional programmers aren't going to be happy at all... Unless I'm mistaken n + sum(n-1) isn't a tail call since it has to add n to the result of sum(n-1) which prevents it from optimizing the call. The following code runs without any errors, though it prints the wrong answer (probably due to overflow) let rec sum n total = if n < 1 then total else sum (n-1) (total + n);; print_int(sum 1000000 0);; best regards Mark Sparshatt