mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
style fixes
This commit is contained in:
parent
364890ca36
commit
3b8f7099cb
2 changed files with 9 additions and 10 deletions
|
|
@ -258,20 +258,19 @@ module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct
|
||||||
let delete_one eq x h =
|
let delete_one eq x h =
|
||||||
let rec aux = function
|
let rec aux = function
|
||||||
| E -> false, E
|
| E -> false, E
|
||||||
| N(_, y, l, r) as h -> begin
|
| N(_, y, l, r) as h ->
|
||||||
if eq x y then true, merge l r
|
if eq x y then true, merge l r
|
||||||
else begin
|
else (
|
||||||
if E.leq y x
|
if E.leq y x
|
||||||
then begin
|
then (
|
||||||
let found_left, l1 = aux l in
|
let found_left, l1 = aux l in
|
||||||
let found, r1 = if found_left then true, r else aux r in
|
let found, r1 = if found_left then true, r else aux r in
|
||||||
if found
|
if found
|
||||||
then true, _make_node y l1 r1
|
then true, _make_node y l1 r1
|
||||||
else false, h
|
else false, h
|
||||||
end
|
)
|
||||||
else false, h
|
else false, h
|
||||||
end
|
)
|
||||||
end
|
|
||||||
in
|
in
|
||||||
snd (aux h)
|
snd (aux h)
|
||||||
|
|
||||||
|
|
@ -279,11 +278,11 @@ module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct
|
||||||
| E -> E
|
| E -> E
|
||||||
| N (_, y, l, r) as h ->
|
| N (_, y, l, r) as h ->
|
||||||
if eq x y then merge (delete_all eq x l) (delete_all eq x r)
|
if eq x y then merge (delete_all eq x l) (delete_all eq x r)
|
||||||
else begin
|
else (
|
||||||
if E.leq y x
|
if E.leq y x
|
||||||
then _make_node y (delete_all eq x l) (delete_all eq x r)
|
then _make_node y (delete_all eq x l) (delete_all eq x r)
|
||||||
else h
|
else h
|
||||||
end
|
)
|
||||||
|
|
||||||
let rec iter f h = match h with
|
let rec iter f h = match h with
|
||||||
| E -> ()
|
| E -> ()
|
||||||
|
|
|
||||||
|
|
@ -858,13 +858,13 @@ let head_opt = function
|
||||||
let tail_opt = function
|
let tail_opt = function
|
||||||
| [] -> None
|
| [] -> None
|
||||||
| _ :: tail -> Some tail
|
| _ :: tail -> Some tail
|
||||||
|
|
||||||
(*$= & ~printer:Q.Print.(option (list int))
|
(*$= & ~printer:Q.Print.(option (list int))
|
||||||
(Some [2;3]) (tail_opt [1;2;3])
|
(Some [2;3]) (tail_opt [1;2;3])
|
||||||
(Some []) (tail_opt [1])
|
(Some []) (tail_opt [1])
|
||||||
None (tail_opt [])
|
None (tail_opt [])
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let rec last_opt = function
|
let rec last_opt = function
|
||||||
| [] -> None
|
| [] -> None
|
||||||
| [x] -> Some x
|
| [x] -> Some x
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue