Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Prove that the following grammar is ambiguous: SA AA+Aid id a | b C

Answered: 1 week ago