let range ?until n = let stop = Option.value_map until ~default:(fun _ -> false) ~f:( < ) in unfold n (fun i -> if stop i then None else Some (i, i + 1))