Demo entry 6641507

intset.ml

   

Submitted by anonymous on Sep 18, 2017 at 19:32
Language: OCaml. Code size: 310 Bytes.

module type EQ = sig
  type t
  val eq: t -> t -> bool
end
module MakeSet (Eq: EQ) = struct
  type elt = Eq.t
  type set = Eq.t list
  let rec member elt = function
  | [] -> false
  | elt' :: set' ->
    Eq.eq elt elt' || member elt set'
end
module IntSet = MakeSet (struct
  type t = int
  let eq = (=)
end)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).