mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 11:15:32 -05:00
test Sequence.rev, since its implementation is non totally trivial
This commit is contained in:
parent
8e9842c2b6
commit
64f7afb6a7
2 changed files with 4 additions and 2 deletions
|
|
@ -69,7 +69,9 @@ let drop n seq =
|
|||
(** Reverse the sequence. O(n) memory. *)
|
||||
let rev seq =
|
||||
let seq_fun k =
|
||||
(* continuation for the prefix of the input sequence so far *)
|
||||
(* if we have traversed [s_1, ..., s_m], [cont ()] will call [k] on s_m,
|
||||
s_{m-1}, ..., s_1. Once we know [s_{m+1}], we update [cont] so that it
|
||||
first returns it, and then called the previous cont. *)
|
||||
let cont = ref (fun () -> ()) in
|
||||
iter (fun x ->
|
||||
let current_cont = !cont in
|
||||
|
|
|
|||
2
tests.ml
2
tests.ml
|
|
@ -22,7 +22,7 @@ let _ =
|
|||
(Sequence.map (fun (x, y) -> (string_of_int x) ^ " -> " ^ (string_of_int y))
|
||||
(Sequence.Hashtbl.to_seq h))
|
||||
in
|
||||
let l3 = Sequence.List.of_seq (Sequence.Int.range ~start:0 ~stop:42) in
|
||||
let l3 = Sequence.List.of_seq (Sequence.rev (Sequence.Int.range ~start:0 ~stop:42)) in
|
||||
Format.printf "l=@[<h>[%a]@]@." (pp_list Format.pp_print_int) l;
|
||||
Format.printf "l'=@[<h>[%a]@]@." (pp_list Format.pp_print_int) l';
|
||||
Format.printf "l''=@[<h>[%a]@]@." (pp_list Format.pp_print_int) l'';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue