mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
bugfix in CCKList.take, it was slightly too eager
This commit is contained in:
parent
80b0f9b820
commit
ec0e92da35
1 changed files with 5 additions and 4 deletions
|
|
@ -101,10 +101,11 @@ let iteri f l =
|
||||||
|
|
||||||
let length l = fold (fun acc _ -> acc+1) 0 l
|
let length l = fold (fun acc _ -> acc+1) 0 l
|
||||||
|
|
||||||
let rec take n (l:'a t) () = match l () with
|
let rec take n (l:'a t) () =
|
||||||
| _ when n=0 -> `Nil
|
if n=0 then `Nil
|
||||||
| `Nil -> `Nil
|
else match l () with
|
||||||
| `Cons (x,l') -> `Cons (x, take (n-1) l')
|
| `Nil -> `Nil
|
||||||
|
| `Cons (x,l') -> `Cons (x, take (n-1) l')
|
||||||
|
|
||||||
let rec take_while p l () = match l () with
|
let rec take_while p l () = match l () with
|
||||||
| `Nil -> `Nil
|
| `Nil -> `Nil
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue