mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Use pattern-matching instead of List.hd and List.tl.
This commit is contained in:
parent
1cdfa06c68
commit
84af4f6f2e
1 changed files with 5 additions and 5 deletions
|
|
@ -58,13 +58,13 @@ module Zipper = struct
|
||||||
let tree zipper = zipper.tree
|
let tree zipper = zipper.tree
|
||||||
|
|
||||||
let left_sibling zipper =
|
let left_sibling zipper =
|
||||||
match zipper.lefts with
|
let rev_lefts = List.rev zipper.lefts in
|
||||||
|
match rev_lefts with
|
||||||
| [] -> None
|
| [] -> None
|
||||||
| lefts ->
|
| last_left::tail_rev_lefts ->
|
||||||
let rev_lefts = List.rev lefts in
|
|
||||||
Some {
|
Some {
|
||||||
tree = List.hd rev_lefts ;
|
tree = last_left ;
|
||||||
lefts = List.tl rev_lefts |> List.rev ;
|
lefts = tail_rev_lefts |> List.rev ;
|
||||||
rights = zipper.tree::zipper.rights ;
|
rights = zipper.tree::zipper.rights ;
|
||||||
parents = zipper.parents
|
parents = zipper.parents
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue