Advertisement
Guest User

Untitled

a guest
Dec 1st, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.25 KB | None | 0 0
  1. module NonEmptyList = struct
  2.   type 'a t = Cons of 'a * 'a t | Nil of 'a
  3.  
  4.   let rec from_list l = match l with
  5.   |[]-> None
  6.   |x::xs ->
  7.     begin match from_list xs with
  8.     | None -> Some (Nil a)
  9.     | Some r ->  Some(Cons (x , r))
  10.     end
  11.  
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement