Commit 7f46a774 authored by POTTIER Francois's avatar POTTIER Francois

Added [add_cutoff].

parent f1c63061
......@@ -84,6 +84,18 @@ let add_lazy p1 p2 =
| _ ->
add p1 (p2())
let add_cutoff cutoff p1 p2 =
match p1 with
| Infinity ->
Infinity
| Finite (i1, _) ->
if cutoff <= i1 then
(* Cut. No need to evaluate [p2]. *)
Infinity
else
(* Evaluate [p2], with an adjusted cutoff value. *)
add p1 (p2 (cutoff - i1))
let print conv p =
match p with
| Finite (i, xs) ->
......
......@@ -22,6 +22,7 @@ val min_lazy: 'a t -> (unit -> 'a t) -> 'a t
val add_lazy: 'a t -> (unit -> 'a t) -> 'a t
val min_cutoff: 'a t -> (int -> 'a t) -> 'a t
val add_cutoff: (* cutoff: *) int -> 'a t -> (int -> 'a t) -> 'a t
val until_finite: 'a t -> (unit -> 'a t) -> 'a t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment