mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
Merge pull request #184 from rand00/master
Fixed bug in ``CCRAL.{drop,take_drop}`
This commit is contained in:
commit
72838b6ebc
2 changed files with 7 additions and 2 deletions
|
|
@ -25,4 +25,5 @@
|
|||
- Fabian Hemmer (copy)
|
||||
- Maciej Woś (@lostman)
|
||||
- Orbifx (Stavros Polymenis)
|
||||
- Dave Aitken (@actionshrimp)
|
||||
- Rand (@rand00)
|
||||
- Dave Aitken (@actionshrimp)
|
||||
|
|
|
|||
|
|
@ -337,11 +337,15 @@ and drop_tree_ ~size n t tail = match t with
|
|||
| Node (_,l,r) ->
|
||||
if n=1 then append_tree_ l (append_tree_ r tail)
|
||||
else
|
||||
let size' = size/2 in
|
||||
let size' = if size mod 2 <> 0 then (size/2)+1 else size/2 in
|
||||
if n-1 < size'
|
||||
then drop_tree_ ~size:size' (n-1) l (append_tree_ r tail)
|
||||
else drop_tree_ ~size:size' (n-1-size') r tail
|
||||
|
||||
(*$T
|
||||
of_list [1;2;3] |> drop 2 |> length = 1
|
||||
*)
|
||||
|
||||
let drop_while ~f l =
|
||||
let rec aux p st = match st with
|
||||
| St_nil -> Nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue