mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 19:25:28 -05:00
tests
This commit is contained in:
parent
556d10a0d4
commit
78551b5e84
1 changed files with 10 additions and 0 deletions
|
|
@ -52,6 +52,12 @@ let repeat ?n x = match n with
|
||||||
| None -> _forever x
|
| None -> _forever x
|
||||||
| Some n -> _repeat n x
|
| Some n -> _repeat n x
|
||||||
|
|
||||||
|
(*$T
|
||||||
|
repeat ~n:4 0 |> to_list = [0;0;0;0]
|
||||||
|
repeat ~n:0 1 |> to_list = []
|
||||||
|
repeat 1 |> take 20 |> to_list = (repeat ~n:20 1 |> to_list)
|
||||||
|
*)
|
||||||
|
|
||||||
let is_empty l = match l () with
|
let is_empty l = match l () with
|
||||||
| `Nil -> true
|
| `Nil -> true
|
||||||
| `Cons _ -> false
|
| `Cons _ -> false
|
||||||
|
|
@ -141,6 +147,10 @@ let rec append l1 l2 () = match l1 () with
|
||||||
|
|
||||||
let rec cycle l () = append l (cycle l) ()
|
let rec cycle l () = append l (cycle l) ()
|
||||||
|
|
||||||
|
(*$T
|
||||||
|
cycle (of_list [1;2]) |> take 5 |> to_list = [1;2;1;2;1]
|
||||||
|
*)
|
||||||
|
|
||||||
let rec flat_map f l () = match l () with
|
let rec flat_map f l () = match l () with
|
||||||
| `Nil -> `Nil
|
| `Nil -> `Nil
|
||||||
| `Cons (x, l') ->
|
| `Cons (x, l') ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue