Compare commits

..

No commits in common. "eab2e1d33f5dddc8603e02636ea9c5d57906aa81" and "c1b13f1c7f0e465e3b27ea4cb69fbe71b0c3f520" have entirely different histories.

3 changed files with 9 additions and 33 deletions

View file

@ -778,12 +778,6 @@ let sorted_diff_uniq ~cmp l1 l2 =
in
recurse ~cmp [] l1 l2
let rec drop n l =
match l with
| [] -> []
| _ when n = 0 -> l
| _ :: l' -> drop (n - 1) l'
[@@@iflt 4.14]
let take n l =
@ -804,8 +798,6 @@ let take n l =
in
direct direct_depth_default_ n l
let take_drop n l = take n l, drop n l
[@@@else_]
let[@tail_mod_cons] rec take n l =
@ -817,29 +809,20 @@ let[@tail_mod_cons] rec take n l =
else
[]
let take_drop n l =
(* fun idea from nojb in
https://discuss.ocaml.org/t/efficient-implementation-of-list-split/17616/2 *)
let[@tail_mod_cons] rec loop (res_drop : _ ref) n l =
match l with
| [] -> []
| x :: tl ->
if n = 0 then (
res_drop := l;
[]
) else
x :: loop res_drop (n - 1) tl
in
let res_drop = ref [] in
let res_take = loop res_drop n l in
res_take, !res_drop
[@@@endif]
let rec drop n l =
match l with
| [] -> []
| _ when n = 0 -> l
| _ :: l' -> drop (n - 1) l'
let hd_tl = function
| [] -> failwith "hd_tl"
| x :: l -> x, l
let take_drop n l = take n l, drop n l
let sublists_of_len ?(last = fun _ -> None) ?offset n l =
if n < 1 then invalid_arg "sublists_of_len: n must be > 0";
let offset =

View file

@ -31,5 +31,5 @@ let uniformity_test ?(size_hint = 10) k rng st =
let () =
let st = Random.State.make_self_init () in
let ok = run ~st (uniformity_test 500_000 (split_list 10 ~len:3)) in
let ok = run ~st (uniformity_test 50_000 (split_list 10 ~len:3)) in
if not ok then failwith "uniformity check failed"

View file

@ -721,13 +721,6 @@ q
let i = abs i in
let l1, l2 = take_drop i l in
l1 @ l2 = l)
;;
q
(Q.pair (Q.list Q.small_int) Q.int)
(fun (l, i) ->
let i = abs i in
take_drop i l = (take i l, drop i l))
let subs = sublists_of_len;;