test Sequence.rev, since its implementation is non totally trivial

This commit is contained in:
Simon Cruanes 2013-01-28 01:16:18 +01:00
parent 8e9842c2b6
commit 64f7afb6a7
2 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -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'';