mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-08 12:15:32 -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)
|
List.rev (List.rev_map f l) = map f l)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
let (>|=) l f = map f l
|
||||||
|
|
||||||
let append l1 l2 =
|
let append l1 l2 =
|
||||||
let rec direct i l1 l2 = match l1 with
|
let rec direct i l1 l2 = match l1 with
|
||||||
| [] -> l2
|
| [] -> l2
|
||||||
|
|
@ -497,7 +499,7 @@ module Zipper = struct
|
||||||
| l, x::r ->
|
| l, x::r ->
|
||||||
begin match f (Some x) with
|
begin match f (Some x) with
|
||||||
| None -> l,r
|
| None -> l,r
|
||||||
| Some x' -> l, x::r
|
| Some _ -> l, x::r
|
||||||
end
|
end
|
||||||
|
|
||||||
let focused = function
|
let focused = function
|
||||||
|
|
@ -661,7 +663,7 @@ let of_klist l =
|
||||||
|
|
||||||
let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l =
|
let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l =
|
||||||
let rec print l = match l with
|
let rec print l = match l with
|
||||||
| x::((y::xs) as l) ->
|
| x::((_::_) as l) ->
|
||||||
pp_item buf x;
|
pp_item buf x;
|
||||||
Buffer.add_string buf sep;
|
Buffer.add_string buf sep;
|
||||||
print l
|
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 print ?(start="[") ?(stop="]") ?(sep=", ") pp_item fmt l =
|
||||||
let rec print fmt l = match l with
|
let rec print fmt l = match l with
|
||||||
| x::((y::xs) as l) ->
|
| x::((_::_) as l) ->
|
||||||
pp_item fmt x;
|
pp_item fmt x;
|
||||||
Format.pp_print_string fmt sep;
|
Format.pp_print_string fmt sep;
|
||||||
Format.pp_print_cut fmt ();
|
Format.pp_print_cut fmt ();
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ val empty : 'a t
|
||||||
val map : ('a -> 'b) -> 'a t -> 'b t
|
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||||
(** Safe version of map *)
|
(** 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
|
val append : 'a t -> 'a t -> 'a t
|
||||||
(** Safe version of append *)
|
(** Safe version of append *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue