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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started