Guest User

Untitled

a guest
Jul 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. let left (Loc(t, p)) =
  2. match p with
  3. | Top -> failwith "left at top"
  4. | Node(l::left, up, right) -> Loc(l, Node(left, up, t::right))
  5. | Node([], up, right) -> failwith "left of first"
  6.  
  7. let right (Loc(t, p)) =
  8. match p with
  9. | Top -> failwith "right at top"
  10. | Node(left, up, r::right) -> Loc(r, Node(t::left, up, right))
  11. | _ -> failwith "right of last"
  12.  
  13. let up (Loc(t, p)) =
  14. match p with
  15. | Top -> failwith "up at top"
  16. | Node (left, up, right) -> Loc(Section((List.rev left) @ (t::right)), up)
  17.  
  18. let down (Loc(t, p)) =
  19. match t with
  20. | Item(_) -> failwith "down with item"
  21. | Section(t1::trees) -> Loc(t1, Node([], p, trees))
  22. | _ -> failwith "down of empty"
Add Comment
Please, Sign In to add comment