Files
rose-ash/lib/ocaml/test.sh
giles 2d519461c4
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
ocaml: phase 6 Seq module (eager, list-backed) (+4 tests, 576 total)
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
2026-05-09 05:56:10 +00:00

103 KiB
Executable File