mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 03:05:29 -05:00
fix(map_by_2): Fixed formatting
This commit is contained in:
parent
20ca1431fc
commit
f56e6d2475
2 changed files with 13 additions and 8 deletions
|
|
@ -114,7 +114,9 @@ let map_by_2 f seq k =
|
||||||
let f y =
|
let f y =
|
||||||
match !r with
|
match !r with
|
||||||
| None -> r := Some y
|
| None -> r := Some y
|
||||||
| Some x -> r := None; k (f x y)
|
| Some x ->
|
||||||
|
r := None;
|
||||||
|
k (f x y)
|
||||||
in
|
in
|
||||||
seq f;
|
seq f;
|
||||||
match !r with
|
match !r with
|
||||||
|
|
|
||||||
|
|
@ -351,16 +351,19 @@ let () =
|
||||||
(* map_by_2 tests *)
|
(* map_by_2 tests *)
|
||||||
let test = OUnit.assert_equal ~printer:Q.Print.(list int)
|
let test = OUnit.assert_equal ~printer:Q.Print.(list int)
|
||||||
let () = test [] (map_by_2 (fun a _ -> a) (of_list []) |> to_list)
|
let () = test [] (map_by_2 (fun a _ -> a) (of_list []) |> to_list)
|
||||||
|
|
||||||
(* Test empty iterator *)
|
(* Test empty iterator *)
|
||||||
let () = test [ 1 ] (map_by_2 (fun _ b -> b) (of_list [ 1 ]) |> to_list)
|
let () = test [ 1 ] (map_by_2 (fun _ b -> b) (of_list [ 1 ]) |> to_list)
|
||||||
let () = test [ 3 ] (map_by_2 (fun _ b -> b) (1 -- 3) |> drop 1 |> to_list)
|
let () = test [ 3 ] (map_by_2 (fun _ b -> b) (1 -- 3) |> drop 1 |> to_list)
|
||||||
let () = test [ 9 ] (map_by_2 (fun _ b -> b) (1 -- 9) |> drop 4 |> to_list)
|
let () = test [ 9 ] (map_by_2 (fun _ b -> b) (1 -- 9) |> drop 4 |> to_list)
|
||||||
|
|
||||||
(* Odd number of elements should leave the last element in the iterator.
|
(* Odd number of elements should leave the last element in the iterator.
|
||||||
For an increasing integer range [1,2k] (fun _ b -> b) returns only
|
For an increasing integer range [1,2k] (fun _ b -> b) returns only
|
||||||
even numbers so this is sufficient to test that this element is left
|
even numbers so this is sufficient to test that this element is left
|
||||||
in the iterator. *)
|
in the iterator. *)
|
||||||
let () = test [ 1 ] (map_by_2 (fun a _ -> a) (1 -- 2) |> to_list)
|
let () = test [ 1 ] (map_by_2 (fun a _ -> a) (1 -- 2) |> to_list)
|
||||||
let () = test [ 2 ] (map_by_2 (fun _ b -> b) (1 -- 2) |> to_list)
|
let () = test [ 2 ] (map_by_2 (fun _ b -> b) (1 -- 2) |> to_list)
|
||||||
|
|
||||||
(* Test two elements *)
|
(* Test two elements *)
|
||||||
let () = test [ 1; 3; 5; 7; 9 ] (map_by_2 (fun a _ -> a) (1 -- 10) |> to_list)
|
let () = test [ 1; 3; 5; 7; 9 ] (map_by_2 (fun a _ -> a) (1 -- 10) |> to_list)
|
||||||
let () = test [ 2; 4; 6; 8; 10 ] (map_by_2 (fun _ b -> b) (1 -- 10) |> to_list)
|
let () = test [ 2; 4; 6; 8; 10 ] (map_by_2 (fun _ b -> b) (1 -- 10) |> to_list)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue