mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
CCList.(>|=) map operator
This commit is contained in:
parent
81a640cf56
commit
dc7b774120
2 changed files with 10 additions and 4 deletions
|
|
@ -51,6 +51,8 @@ let map f l =
|
|||
List.rev (List.rev_map f l) = map f l)
|
||||
*)
|
||||
|
||||
let (>|=) l f = map f l
|
||||
|
||||
let append l1 l2 =
|
||||
let rec direct i l1 l2 = match l1 with
|
||||
| [] -> l2
|
||||
|
|
@ -497,7 +499,7 @@ module Zipper = struct
|
|||
| l, x::r ->
|
||||
begin match f (Some x) with
|
||||
| None -> l,r
|
||||
| Some x' -> l, x::r
|
||||
| Some _ -> l, x::r
|
||||
end
|
||||
|
||||
let focused = function
|
||||
|
|
@ -661,7 +663,7 @@ let of_klist l =
|
|||
|
||||
let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l =
|
||||
let rec print l = match l with
|
||||
| x::((y::xs) as l) ->
|
||||
| x::((_::_) as l) ->
|
||||
pp_item buf x;
|
||||
Buffer.add_string buf sep;
|
||||
print l
|
||||
|
|
@ -675,7 +677,7 @@ let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l =
|
|||
|
||||
let print ?(start="[") ?(stop="]") ?(sep=", ") pp_item fmt l =
|
||||
let rec print fmt l = match l with
|
||||
| x::((y::xs) as l) ->
|
||||
| x::((_::_) as l) ->
|
||||
pp_item fmt x;
|
||||
Format.pp_print_string fmt sep;
|
||||
Format.pp_print_cut fmt ();
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ val empty : 'a t
|
|||
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||
(** Safe version of map *)
|
||||
|
||||
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
||||
(** Infix version of [map] with reversed arguments
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val append : 'a t -> 'a t -> 'a t
|
||||
(** Safe version of append *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue