Permalink
Browse files

Merge pull request #398 from UnixJunkie/master

fix broken test
  • Loading branch information...
2 parents 63f9e4b + a970f5a commit 11e5e9a331d2f8ab3e87d9c64d58480c619bdbbd @gasche gasche committed Jun 20, 2013
Showing with 18 additions and 11 deletions.
  1. +18 −11 src/batList.ml
View
@@ -257,7 +257,7 @@ let nsplit p = function
dummy.tl
(*$T nsplit
- nsplit ((=) 0) [] = [[]]
+ nsplit ((=) 0) [] = []
nsplit ((=) 0) [0] = [[]; []]
nsplit ((=) 0) [1; 0] = [[1]; []]
nsplit ((=) 0) [0; 1] = [[]; [1]]
@@ -609,16 +609,23 @@ let split lst =
adummy.tl, bdummy.tl
let combine l1 l2 =
- let rec loop dst l1 l2 =
- match l1, l2 with
- | [], [] -> ()
- | h1 :: t1, h2 :: t2 ->
- loop (Acc.accum dst (h1, h2)) t1 t2
- | _, _ -> invalid_arg "combine: Different_list_size"
- in
- let dummy = Acc.dummy () in
- loop dummy l1 l2;
- dummy.tl
+ let list_sizes_differ = Invalid_argument "combine: Different_list_size" in
+ match l1, l2 with
+ | [], [] -> []
+ | x :: xs, y :: ys ->
+ let acc = { hd = (x, y); tl = [] } in
+ let rec loop dst l1 l2 = match l1, l2 with
+ | [], [] -> inj acc
+ | h1 :: t1, h2 :: t2 -> loop (Acc.accum dst (h1, h2)) t1 t2
+ | _, _ -> raise list_sizes_differ
+ in loop acc xs ys
+ | _, _ -> raise list_sizes_differ
+
+(*$T combine
+ combine [] [] = []
+ combine [1] [2] = [(1, 2)]
+ combine [1; 3] [2; 4] = [(1, 2); (3, 4)]
+*)
let rec init size f =
if size = 0 then []

0 comments on commit 11e5e9a

Please sign in to comment.