mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-01-28 03:44:51 -05:00
do simplify the code a bit
closer to the original solution, too. Avoids a redundant `:= []`.
This commit is contained in:
parent
ddc87518a7
commit
c72b60fd6f
1 changed files with 8 additions and 8 deletions
|
|
@ -821,14 +821,14 @@ let take_drop n l =
|
||||||
(* fun idea from nojb in
|
(* fun idea from nojb in
|
||||||
https://discuss.ocaml.org/t/efficient-implementation-of-list-split/17616/2 *)
|
https://discuss.ocaml.org/t/efficient-implementation-of-list-split/17616/2 *)
|
||||||
let[@tail_mod_cons] rec loop (res_drop : _ ref) n l =
|
let[@tail_mod_cons] rec loop (res_drop : _ ref) n l =
|
||||||
match n, l with
|
match l with
|
||||||
| 0, _ ->
|
| [] -> []
|
||||||
res_drop := l;
|
| x :: tl ->
|
||||||
[]
|
if n = 0 then (
|
||||||
| _, [] ->
|
res_drop := l;
|
||||||
res_drop := [];
|
[]
|
||||||
[]
|
) else
|
||||||
| _, x :: tl -> x :: loop res_drop (n - 1) tl
|
x :: loop res_drop (n - 1) tl
|
||||||
in
|
in
|
||||||
let res_drop = ref [] in
|
let res_drop = ref [] in
|
||||||
let res_take = loop res_drop n l in
|
let res_take = loop res_drop n l in
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue