whitespace

This commit is contained in:
Simon Cruanes 2017-07-29 19:24:37 +02:00
parent bedf9ecc1e
commit c575f97369
2 changed files with 7 additions and 7 deletions

View file

@ -387,8 +387,8 @@ let combine_gen l1 l2 =
res1 = res2) res1 = res2)
*) *)
let split l = let split l =
let rec direct i l = match l with let rec direct i l = match l with
| [] -> [], [] | [] -> [], []
| [x1, y1] -> [x1], [y1] | [x1, y1] -> [x1], [y1]
| [x1, y1; x2, y2] -> [x1;x2], [y1;y2] | [x1, y1; x2, y2] -> [x1;x2], [y1;y2]
@ -396,19 +396,19 @@ let split l =
| [x1, y1; x2, y2; x3, y3; x4, y4] -> [x1;x2;x3;x4], [y1;y2;y3;y4] | [x1, y1; x2, y2; x3, y3; x4, y4] -> [x1;x2;x3;x4], [y1;y2;y3;y4]
| _ when i=0 -> split_slow [] [] l | _ when i=0 -> split_slow [] [] l
| (x1, y1) :: (x2, y2) :: (x3, y3) :: (x4, y4) :: (x5, y5) :: l' -> | (x1, y1) :: (x2, y2) :: (x3, y3) :: (x4, y4) :: (x5, y5) :: l' ->
let rx, ry = direct (i-1) l' in let rx, ry = direct (i-1) l' in
x1 :: x2 :: x3 :: x4 :: x5 :: rx, x1 :: x2 :: x3 :: x4 :: x5 :: rx,
y1 :: y2 :: y3 :: y4 :: y5 :: ry y1 :: y2 :: y3 :: y4 :: y5 :: ry
and split_slow acc1 acc2 l = match l with and split_slow acc1 acc2 l = match l with
| [] -> List.rev acc1, List.rev acc2 | [] -> List.rev acc1, List.rev acc2
| (x1, x2) :: tail -> | (x1, x2) :: tail ->
let acc1 = x1 :: acc1 let acc1 = x1 :: acc1
and acc2 = x2 :: acc2 in and acc2 = x2 :: acc2 in
split_slow acc1 acc2 tail split_slow acc1 acc2 tail
in in
direct direct_depth_default_ l direct direct_depth_default_ l
(*$Q (*$Q
(Q.(list_of_size Gen.(0--10_000) (pair small_int small_string))) (fun l -> \ (Q.(list_of_size Gen.(0--10_000) (pair small_int small_string))) (fun l -> \
let (l1, l2) = split l in \ let (l1, l2) = split l in \
List.length l1 = List.length l \ List.length l1 = List.length l \

View file

@ -92,7 +92,7 @@ val combine_gen : 'a list -> 'b list -> ('a * 'b) gen
instead, the output has as many pairs as the smallest input list. instead, the output has as many pairs as the smallest input list.
@since 1.2 *) @since 1.2 *)
val split : ('a * 'b) t -> 'a t * 'b t val split : ('a * 'b) t -> 'a t * 'b t
(** A tail-recursive version of {!List.split}. *) (** A tail-recursive version of {!List.split}. *)
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int