Jensen's Device: Difference between revisions

Line 146:
 
=={{header|OCaml}}==
{{trans|Python}}
<ocaml>let i = ref 42 (* initial value doesn't matter *)
 
let sum' i lo hi term =
let recresult aux= accref =0. in
if !i > hi:= thenlo;
while !i acc<= hi do
auxresult (acc:= !result +. term ());
else begin
incr i;
done;
aux (acc +. term ())
end!result
in
i := lo - 1;
aux 0.
 
let () =
Anonymous user