Exercise: date order [**] Here is a type for dates: type date = {month : int; day : int} For example, March 31st would be represented as {month = 3; day 31}. Our goal in the %3! next few exercises is...


please use ocaml for the programming language. DO NOT code in any other language ONLY OCAML


Exercise: date order [**]<br>Here is a type for dates:<br>type date = {month : int; day : int}<br>For example, March 31st would be represented as {month<br>= 3; day<br>31}. Our goal in the<br>%3!<br>next few exercises is to implement a map whose keys have type date.<br>Obviously it's possible to represent invalid dates with type date-for example, { month=6;<br>day=50 } would be June 50th, which is not a real date. The behavior of your code in the<br>exercises below is unspecified for invalid dates.<br>To create a map over dates, we need a module that we can pass as input to Map.Make. That<br>module will need to match the Map.OrderedType signature. Create such a module. Here is<br>some code to get you started:<br>module Date = struct<br>type t = date<br>let compare ...<br>end<br>Recall the specification of compare in Map.OrderedType as you write your Date.compare<br>function.<br>

Extracted text: Exercise: date order [**] Here is a type for dates: type date = {month : int; day : int} For example, March 31st would be represented as {month = 3; day 31}. Our goal in the %3! next few exercises is to implement a map whose keys have type date. Obviously it's possible to represent invalid dates with type date-for example, { month=6; day=50 } would be June 50th, which is not a real date. The behavior of your code in the exercises below is unspecified for invalid dates. To create a map over dates, we need a module that we can pass as input to Map.Make. That module will need to match the Map.OrderedType signature. Create such a module. Here is some code to get you started: module Date = struct type t = date let compare ... end Recall the specification of compare in Map.OrderedType as you write your Date.compare function.

Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here