ocaml: phase 6 String.iter/iteri/fold_left/fold_right/to_seq/of_seq (+3 tests, 501 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Six new String functions, all in OCaml syntax inside runtime.sx: iter : index-walk with side-effecting f iteri : iter with index fold_left : thread accumulator left-to-right fold_right: thread accumulator right-to-left to_seq : return a char list (lazy in real OCaml; eager here) of_seq : concat a char list back to a string Round-trip: String.of_seq (List.rev (String.to_seq "hello")) = "olleh" Note: real OCaml's Seq is lazy. We return a plain list because the existing stdlib already provides exhaustive list operations and we don't yet have lazy sequences. If a baseline needs Seq.unfold or similar, we'll graduate to a proper Seq module then.
This commit is contained in:
@@ -407,6 +407,13 @@ _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 — 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 +
|
||||
side-effecting `f`, fold_left / fold_right thread an accumulator,
|
||||
to_seq returns a char list, of_seq concats a char list back to a
|
||||
string. Round-trip: `String.of_seq (List.rev (String.to_seq
|
||||
"hello"))` → "olleh".
|
||||
- 2026-05-09 Phase 5.1 — frequency.ml baseline + Format module alias
|
||||
(+2 tests, 498 total). frequency.ml builds a Hashtbl of char→count
|
||||
via `Hashtbl.find_opt` + `Hashtbl.replace` inside a `for` loop, then
|
||||
|
||||
Reference in New Issue
Block a user