mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCList.cons_maybe
This commit is contained in:
parent
290ba2810a
commit
5069580a9d
2 changed files with 14 additions and 0 deletions
|
|
@ -82,6 +82,15 @@ let (@) = append
|
||||||
(1-- 10_000) @ (10_001 -- 20_000) = 1 -- 20_000
|
(1-- 10_000) @ (10_001 -- 20_000) = 1 -- 20_000
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
let cons_maybe o l = match o with
|
||||||
|
| Some x -> x :: l
|
||||||
|
| None -> l
|
||||||
|
|
||||||
|
(*$T
|
||||||
|
cons_maybe (Some 1) [2;3] = [1;2;3]
|
||||||
|
cons_maybe None [2;3] = [2;3]
|
||||||
|
*)
|
||||||
|
|
||||||
let direct_depth_filter_ = 10_000
|
let direct_depth_filter_ = 10_000
|
||||||
|
|
||||||
let filter p l =
|
let filter p l =
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,11 @@ val cons : 'a -> 'a t -> 'a t
|
||||||
val append : 'a t -> 'a t -> 'a t
|
val append : 'a t -> 'a t -> 'a t
|
||||||
(** Safe version of append *)
|
(** Safe version of append *)
|
||||||
|
|
||||||
|
val cons_maybe : 'a option -> 'a t -> 'a t
|
||||||
|
(** [cons_maybe (Some x) l] is [x :: l]
|
||||||
|
[cons_maybe None l] is [l]
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val (@) : 'a t -> 'a t -> 'a t
|
val (@) : 'a t -> 'a t -> 'a t
|
||||||
|
|
||||||
val filter : ('a -> bool) -> 'a t -> 'a t
|
val filter : ('a -> bool) -> 'a t -> 'a t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue