mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -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
|
||||
| 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
|
||||
| `Nil -> true
|
||||
| `Cons _ -> false
|
||||
|
|
@ -141,6 +147,10 @@ let rec append l1 l2 () = match l1 () with
|
|||
|
||||
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
|
||||
| `Nil -> `Nil
|
||||
| `Cons (x, l') ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue