Files
rose-ash/lib/ocaml/baseline/expected.json
giles 13fb1bd7a9
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
ocaml: phase 5.1 newton_sqrt.ml baseline (Newton's method, sqrt(2)*1000 = 1414)
Newton's method for square root:

  let sqrt_newton x =
    let g = ref 1.0 in
    for _ = 1 to 20 do
      g := (!g +. x /. !g) /. 2.0
    done;
    !g

20 iterations is more than enough to converge for x=2 — result is
~1.414213562. Multiplied by 1000 and int_of_float'd: 1414.

First baseline exercising:
  - for _ = 1 to N do ... done (wildcard loop variable)
  - pure float arithmetic with +. /.
  - the int_of_float truncate-toward-zero fix from iter 117

38 baseline programs total.
2026-05-09 08:29:01 +00:00

43 lines
859 B
JSON

{
"anagrams.ml": 3,
"bag.ml": 3,
"balance.ml": 3,
"bfs.ml": 6,
"btree.ml": 39,
"brainfuck.ml": 75,
"caesar.ml": 215,
"calc.ml": 13,
"closures.ml": 315,
"csv.ml": 10,
"exception_handle.ml": 4,
"expr_eval.ml": 16,
"factorial.ml": 3628800,
"fraction.ml": 7,
"frequency.ml": 5,
"hanoi.ml": 1023,
"fizzbuzz.ml": 57,
"list_ops.ml": 30,
"json_pretty.ml": 24,
"lambda_calc.ml": 7,
"levenshtein.ml": 11,
"memo_fib.ml": 75025,
"merge_sort.ml": 44,
"module_use.ml": 3,
"newton_sqrt.ml": 1414,
"mutable_record.ml": 10,
"option_match.ml": 5,
"pi_leibniz.ml": 314,
"poly_stack.ml": 5,
"queens.ml": 2,
"quicksort.ml": 44,
"roman.ml": 44,
"safe_div.ml": 20,
"shuffle.ml": 55,
"word_freq.ml": 8,
"sieve.ml": 15,
"sum_squares.ml": 385,
"unique_set.ml": 9,
"validate.ml": 417,
"word_count.ml": 3
}