Question: IntSet (IN ML) module is an abstract data types for sets of integers, represent by type t module type INTSET = sig type t val
IntSet (IN ML) module is an abstract data types for "sets of integers", represent by type t
module type INTSET = sig
type t
val empty : t
val contains : int -> t -> bool
val insert : int -> t -> t
val remove : int -> t -> t
val fold : ('a -> int -> 'a) ->
'a -> t -> 'a
val to_string : t -> string
end
Question: complete module implementation IntSet1 in the "todo section", in your implementation of fold, follow the order of elements in the list. Note that insert can cause duplicates to be in the list.
module IntSet1 : INTSET = struct
type t = int list
let empty = [ ]
let contains = List.mem
let insert = List.cons
let remove = fun _ -> //todo
let fold = fun _ ->//todo
let to_string = fun _ -> //todo
end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
