ocaml: phase 6 Array.sort/sub/append/exists/for_all/mem (+5 tests, 520 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s

Eight new Array functions, all in OCaml syntax inside runtime.sx,
delegating to the corresponding List operation on the cell's
underlying list:

  sort cmp a    -> a := List.sort cmp !a    (* mutates the cell *)
  stable_sort   = sort
  fast_sort     = sort
  append a b    -> ref (List.append !a !b)
  sub a pos n   -> ref (take n (drop pos !a))
  exists p      -> List.exists p !a
  for_all p     -> List.for_all p !a
  mem x a       -> List.mem x !a

Round-trip:
  let a = Array.of_list [3;1;4;1;5;9;2;6] in
  Array.sort compare a;
  Array.to_list a    = [1;1;2;3;4;5;6;9]
This commit is contained in:
2026-05-09 02:35:55 +00:00
parent f68ea63e46
commit 55fe1e4468
3 changed files with 50 additions and 0 deletions

View File

@@ -407,6 +407,12 @@ _Newest first._
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
'a tree`) with insert + in-order traversal. Tests parametric ADT,
recursive match, List.append, List.fold_left.
- 2026-05-09 Phase 6 — Array.sort/stable_sort/fast_sort + sub +
append + exists + for_all + mem (+5 tests, 520 total). All
delegate to the corresponding List operation on the cell's
underlying list (sort mutates by replacing the cell, the rest are
pure observers). Array round-trip via of_list → sort → to_list
works as expected.
- 2026-05-09 Phase 5.1 — brainfuck.ml baseline (subset interpreter,
five `+++++.` groups → cumulative 5+10+15+20+25 = 75). No loop
brackets — the interpreter only handles `> < + - .`, but that's