Commit 5416475d by POTTIER Francois

### Define [Misc.foldij_lazy]. Comment.

parent f08859ed
 ... ... @@ -102,10 +102,6 @@ let iterij i j f = let iteri n f = iterij 0 n f (* [foldi] implements a [for] loop over integers, from 0 to [n-1], with an accumulator. [foldij] implements a [for] loop over integers, from [start] to [n-1], with an accumulator. *) let rec foldij i j f accu = if i < j then foldij (i + 1) j f (f i accu) ... ... @@ -115,6 +111,12 @@ let rec foldij i j f accu = let foldi n f accu = foldij 0 n f accu let rec foldij_lazy i j f accu = if i < j then f i (fun () -> foldij_lazy (i + 1) j f accu) else accu (* [mapij start n f] produces the list [ f start; ... f (n-1) ]. *) let mapij start n f = ... ...
 ... ... @@ -67,15 +67,24 @@ val materialize: ('a, 'a option) Hashtbl.t -> 'a -> 'a list (* [iteri] implements a [for] loop over integers, from 0 to [n-1]. *) val iteri: int -> (int -> unit) -> unit val iteri: int -> (int -> unit) -> unit val iterij: int -> int -> (int -> unit) -> unit (* [foldij i j f accu] iterates on the semi-open interval [i, j), with an accumulator. [foldij_lazy i j f accu] is analogous, but is interruptible: if at some point the function [f] does not demand its second argument, then iteration stops early. [foldij] and [foldij_lazy] iterate in the same direction, from left to right, but do not build the accumulator in the same way: the calls to [f] are associated differently. (In that respect, [foldij] is a left fold, while [foldij_lazy] is a right fold.) *) (* [foldi] implements a [for] loop over integers, from 0 to [n-1], with an accumulator. [foldij] implements a [for] loop over integers, from [start] to [n-1], with an accumulator. *) with an accumulator. *) val foldi: int -> (int -> 'a -> 'a) -> 'a -> 'a val foldij: int -> int -> (int -> 'a -> 'a) -> 'a -> 'a val foldi: int -> (int -> 'a -> 'a) -> 'a -> 'a val foldij: int -> int -> (int -> 'a -> 'a) -> 'a -> 'a val foldij_lazy: int -> int -> (int -> (unit -> 'a) -> 'a) -> 'a -> 'a (* [mapij start n f] produces the list [ f start; ... f (n-1) ]. *) ... ...
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