mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-01-28 20:04:51 -05:00
style: improve new code
This commit is contained in:
parent
509dacb96f
commit
c1704d71ff
2 changed files with 33 additions and 28 deletions
|
|
@ -264,9 +264,10 @@ let update_front d f =
|
||||||
| Some x -> d.cur.cell <- Two (x,y)
|
| Some x -> d.cur.cell <- Two (x,y)
|
||||||
end
|
end
|
||||||
| Three (x,y,z) ->
|
| Three (x,y,z) ->
|
||||||
match f x with
|
begin match f x with
|
||||||
| None -> d.cur.cell <- Two (y,z)
|
| None -> d.cur.cell <- Two (y,z)
|
||||||
| Some x -> d.cur.cell <- Three (x,y,z)
|
| Some x -> d.cur.cell <- Three (x,y,z)
|
||||||
|
end
|
||||||
|
|
||||||
(*$T update_front
|
(*$T update_front
|
||||||
let q = of_list [1;2;3;4;5;6;7] in update_front q (fun _ -> None); to_list q = [2;3;4;5;6;7]
|
let q = of_list [1;2;3;4;5;6;7] in update_front q (fun _ -> None); to_list q = [2;3;4;5;6;7]
|
||||||
|
|
@ -301,9 +302,10 @@ let update_back d f =
|
||||||
| Some y -> n.cell <- Two (x,y)
|
| Some y -> n.cell <- Two (x,y)
|
||||||
end
|
end
|
||||||
| Three (x,y,z) ->
|
| Three (x,y,z) ->
|
||||||
match f z with
|
begin match f z with
|
||||||
| None -> n.cell <- Two (x,y)
|
| None -> n.cell <- Two (x,y)
|
||||||
| Some z -> n.cell <- Three (x,y,z)
|
| Some z -> n.cell <- Three (x,y,z)
|
||||||
|
end
|
||||||
|
|
||||||
(*$T update_back
|
(*$T update_back
|
||||||
let q = of_list [1;2;3;4;5;6;7] in update_back q (fun _ -> None); to_list q = [1;2;3;4;5;6]
|
let q = of_list [1;2;3;4;5;6;7] in update_back q (fun _ -> None); to_list q = [1;2;3;4;5;6]
|
||||||
|
|
|
||||||
|
|
@ -83,10 +83,13 @@ val take_front_opt : 'a t -> 'a option
|
||||||
|
|
||||||
val update_back : 'a t -> ('a -> 'a option) -> unit
|
val update_back : 'a t -> ('a -> 'a option) -> unit
|
||||||
(** Update last value. If the deque is empty do nothing.
|
(** Update last value. If the deque is empty do nothing.
|
||||||
|
If the function returns [None], remove last element;
|
||||||
|
if it returns [Some x], replace last element with [x].
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val update_front : 'a t -> ('a -> 'a option) -> unit
|
val update_front : 'a t -> ('a -> 'a option) -> unit
|
||||||
(** Update first value. If the deque is empty do nothing.
|
(** Update first value. If the deque is empty do nothing.
|
||||||
|
Similar to {!update_back} but for the first value.
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val append_front : into:'a t -> 'a t -> unit
|
val append_front : into:'a t -> 'a t -> unit
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue