ocaml: phase 6 Seq module (eager, list-backed) (+4 tests, 576 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Real OCaml's Seq.t is 'unit -> Cons of elt * Seq.t | Nil' — a lazy
thunk that lets you build infinite sequences. Ours is just a list,
which gives the right shape for everything in baseline programs that
don't rely on laziness (taking from infinite sequences would force
memory).
API: empty, cons, return, is_empty, iter, iteri, map, filter,
filter_map, fold_left, length, take, drop, append, to_list,
of_list, init, unfold.
unfold takes a step fn 'acc -> Option (elt * acc)' and threads
through until it returns None:
Seq.fold_left (+) 0
(Seq.unfold (fun n -> if n > 4 then None
else Some (n, n + 1))
1)
= 1 + 2 + 3 + 4 = 10
This commit is contained in:
@@ -407,6 +407,16 @@ _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 — Seq module (eager, list-backed) (+4 tests,
|
||||
576 total). Real OCaml's Seq is lazy (a thunk producing
|
||||
Cons / Nil); ours is just a list, which is adequate for most
|
||||
baseline programs that don't rely on infinite sequences. API:
|
||||
empty, cons, return, is_empty, iter, iteri, map, filter,
|
||||
filter_map, fold_left, length, take, drop, append, to_list,
|
||||
of_list, init, unfold. unfold takes a step fn `acc -> Option (elt
|
||||
* acc)` and threads through until it returns None. Lets us write
|
||||
`Seq.fold_left (+) 0 (Seq.unfold (fun n -> if n > 4 then None else
|
||||
Some (n, n + 1)) 1)` → 10.
|
||||
- 2026-05-09 Phase 5.1 — unique_set.ml baseline (Set.Make + IntOrd
|
||||
functor app, count uniques in [3;1;4;1;5;9;2;6;5;3;5;8;9;7;9] →
|
||||
9). First baseline that exercises the functor pipeline end to
|
||||
|
||||
Reference in New Issue
Block a user