Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. module type BOX =
  2. sig
  3. type 'a option
  4. exception Err of string
  5. val create: unit -> 'a option (*tworzenie pudełka*)
  6. val put: 'a* 'a option -> 'a option (*wkładanie do pudełka*)
  7. val pop: 'a option -> 'a option (*wyciąganie z pudełka*)
  8. (*val content: 'a option -> 'a*)
  9. end
  10. ;;
  11.  
  12. module Box : BOX =
  13. struct
  14. type 'a option = 'a list
  15. exception Err of string
  16.  
  17. let create() = []
  18. let put = function
  19. | (s, []) -> [s];
  20. | (_, _) -> raise(Err("box is full"))
  21.  
  22. let pop = function
  23. | [] -> raise (Err "Box is empty")
  24. | h -> []
  25. (*
  26. let content = function
  27. | [] -> raise(Err "Box is empty")
  28. | h::_ -> h*)
  29. end
  30. ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement