Answered step by step
Verified Expert Solution
Question
1 Approved Answer
> Complete the quadrant function below, which should return the quadrant of the given x, y point according to the diagram on the right
> Complete the quadrant function below, which should return the quadrant of the given x, y point according to the diagram on the right (borrowed from Wikipedia). Points that lie on an axis do not belong to any quandrant. Hints: (a) define a helper function for the sign of an integer, (b) match against a pair. type quad I | II | III | IV type sign Neg | Zero | Pos let sign (x:int) : sign = let quadrant: int*int >quad option = fu match... with -> Some I II 10 y-axis P(3.5) x-axis -10 5 10 (0.0) origin IV III -10 -> Some II -> Some III -> Some IV -> None Rewrite the quadrant function to use the when syntax. You won't need your helper function from before. let quadrant when ... ... when... when ... when... when ... -> None int int > quad option = function -> Some I -> Some II -> Some III -> Some IV
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