ocaml: phase 6 List.sort_uniq + List.find_map (+2 tests, 503 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s

sort_uniq:
  Sort with the user comparator, then walk the sorted list dropping
  any element equal to its predecessor. Output is sorted and unique.

  List.sort_uniq compare [3;1;2;1;3;2;4]  =  [1;2;3;4]

find_map:
  Walk until the user fn returns Some v; return that. If all None,
  return None.

  List.find_map (fun x -> if x > 5 then Some (x * 2) else None)
                [1;2;3;6;7]
  = Some 12

Both defined in OCaml syntax in runtime.sx — no host primitive
needed since they're pure list traversals over existing operations.
This commit is contained in:
2026-05-09 01:29:02 +00:00
parent 8af3630625
commit a34cfe69dc
3 changed files with 35 additions and 0 deletions

View File

@@ -407,6 +407,11 @@ _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 — List.sort_uniq / List.find_map (+2 tests, 503
total). sort_uniq sorts then dedups consecutive equals. find_map
walks until the user fn returns `Some v` and returns it (or `None`
on empty/all-None). Closes two of the most-asked-for list ops; both
defined in OCaml syntax in runtime.sx.
- 2026-05-09 Phase 6 — String.iter / iteri / fold_left / fold_right /
to_seq / of_seq (+3 tests, 501 total). All implemented in OCaml
syntax inside the runtime stdlib; iter / iteri walk via index +