mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
parent
2f7366be59
commit
b5ecb273ef
3 changed files with 16 additions and 0 deletions
|
|
@ -148,6 +148,12 @@ let (@) = append
|
|||
(1-- 10_000) @ (10_001 -- 20_000) = 1 -- 20_000
|
||||
*)
|
||||
|
||||
let[@inline] cons' l x = x::l
|
||||
|
||||
(*$Q
|
||||
Q.(small_list int)(fun l -> List.rev l = List.fold_left cons' [] l)
|
||||
*)
|
||||
|
||||
let cons_maybe o l = match o with
|
||||
| Some x -> x :: l
|
||||
| None -> l
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ val cons_maybe : 'a option -> 'a t -> 'a t
|
|||
[cons_maybe None l] is [l].
|
||||
@since 0.13 *)
|
||||
|
||||
val cons' : 'a t -> 'a -> 'a t
|
||||
(** [cons' l x] is the same as [x :: l]. This is convenient for fold
|
||||
functions such as {!List.fold_left} or {!Array.fold_left}.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val (@) : 'a t -> 'a t -> 'a t
|
||||
(** [l1 @ l2] is like [append l1 l2].
|
||||
Concatenate the two lists [l1] and [l2]. *)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ val append : 'a t -> 'a t -> 'a t
|
|||
(** [append l1 l2] returns the list that is the concatenation of [l1] and [l2].
|
||||
Safe version of {!List.append}. *)
|
||||
|
||||
val cons' : 'a t -> 'a -> 'a t
|
||||
(** [cons' l x] is the same as [x :: l]. This is convenient for fold
|
||||
functions such as {!List.fold_left} or {!Array.fold_left}.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val cons_maybe : 'a option -> 'a t -> 'a t
|
||||
(** [cons_maybe (Some x) l] is [x :: l].
|
||||
[cons_maybe None l] is [l].
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue