An implementation of finite sets of natural numbers in Standard ML uses an int list as its
Question:
An implementation of finite sets of natural numbers in Standard ML uses an int list as its representation. However, certain client code has been found to be buggy, because it misuses:: to add elements (creating duplicates) and length to obtain the number of elements (miscounting duplicates). (i) Explain how ML modules might be helpful for addressing such bugs. (ii) Use the ML modules language to create a typed dataset that uses an int list internally but only exposes operations (a) to create an empty set, (b) to (functionally) insert one (non-negative) element into a set, (c) to sum the elements in a set, (d) to count the number of elements in a set. No other operation may create or manipulate the latest value.
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts