mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -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 left_sibling zipper =
|
||||
match zipper.lefts with
|
||||
let rev_lefts = List.rev zipper.lefts in
|
||||
match rev_lefts with
|
||||
| [] -> None
|
||||
| lefts ->
|
||||
let rev_lefts = List.rev lefts in
|
||||
| last_left::tail_rev_lefts ->
|
||||
Some {
|
||||
tree = List.hd rev_lefts ;
|
||||
lefts = List.tl rev_lefts |> List.rev ;
|
||||
tree = last_left ;
|
||||
lefts = tail_rev_lefts |> List.rev ;
|
||||
rights = zipper.tree::zipper.rights ;
|
||||
parents = zipper.parents
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue