| lazy (Cons (v, t)) -> !!(fold_left f (f st v) t))

-let rec fold_right f lst st = match lst with

- | lazy (Cons (v, lst)) -> f v (fold_right f lst st)

+let rec fold_right f xs st =

+ | lazy Null -> Lazy.force st

+ | lazy (Cons (x,xs)) -> Lazy.force (f x (fold_right f xs st))

let rec map f lst = lazy (match lst with

| lazy Null -> failwith "fold_left1"

| lazy (Cons (v, t)) -> fold_left f v t

-let rec fold_right1 f lst st = match lst with

+let rec fold_right1 f lst st = lazy match lst with

| lazy Null -> failwith "fold_right1"

| lazy (Cons (v, lazy Null)) -> v

- | lazy (Cons (v, lst)) -> f v (fold_right1 f lst st)

+ | lazy (Cons (v, lst)) -> Lazy.force (f v (fold_right1 f lst st))

let rec mem k t = match t with

let bind t f = concat (map f t)

+TEST "fold_right and map" =

+ let zeros = create (fun () -> Some (0, ())) () in

+ let ones = fold_right (fun z st -> (z+1)^^st) zeros null in

+ let ones' = map (fun z -> z + 1) zeros in

+ to_list (take 3 ones) = [1; 1; 1]

+ && to_list (take 3 ones') = [1; 1; 1]