From: Martin Weber Date: 2003-08-26T02:06:59+09:00 Subject: Re: Rite/Ruby2.0 & Ruby vs OCaml On Tue, Aug 26, 2003 at 01:35:56AM +0900, Brian Candler wrote: > On Tue, Aug 26, 2003 at 12:40:45AM +0900, mark wrote: > (...) > def sum(n) > total = 0 > n.times { |x| total += x } > total > end > > puts sum(1000000) > > OTOH, the Ruby version gives the right answer :-) 1+2+3+4 = 10. sum(4) = 6. ocaml-sum(4) = 10. :) ruby: time -p ruby sum.rb 499999500000 real 11.96 user 11.35 sys 0.00 ocaml1: time -p ./sum1 500000500000 real 19.19 user 17.79 sys 0.04 ocaml2: time -p ./sum2 500000500000 real 3.89 user 3.62 sys 0.00 (check other mail for what is sum1/2) Regards, -Martin