add lecture 08

This commit is contained in:
SowinskiBraeden committed 2026-03-10 13:58:16 -07:00
1 parent 7c3198fee4
commit 9b62c01175
4 files changed
+133

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
type 'a infstream = Cons of 'a * (unit -> 'a infstream)
let hd (Cons (h, _)) = h
let tl (Cons (_, t)) = t ()
let rec from n = Cons (n, fun () -> from (n + 1))
let rec take n (Cons (h, t)) =
if n <= 0 then []
else h :: take (n - 1) (t ())