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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!