Merge pull request #184 from rand00/master

Fixed bug in ``CCRAL.{drop,take_drop}`
This commit is contained in:
Simon Cruanes 2018-02-04 12:07:22 -06:00 committed by GitHub
commit 72838b6ebc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -25,4 +25,5 @@
- Fabian Hemmer (copy)
- Maciej Woś (@lostman)
- Orbifx (Stavros Polymenis)
- Rand (@rand00)
- Dave Aitken (@actionshrimp)

View file

@ -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