Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ocaml: fix the code to realize distance: (int * int) -> (int * int) -> float: Given two points (x1, y1) and (x2, y2), return

Ocaml: fix the code to realize image text in transcribed
distance: (int * int) -> (int * int) -> float: Given two points (x1, y1) and (x2, y2), return the Euclidean distance between the two points, equivalent to the length of a straight line segment connecting the two points. The result should be returned as a floating-point number. let distance_tests = [ (((0, 0), (3, 4)), (5.) ); ( ((@, 0), (1, 1)), (1.4) ); |] let distance ((x1, y1): (int * int)) ((x2, y2): (int * int)) : float = let dx = (x1 - x2) in let dy = (y1 y2) in return sqrt (dx * dx + dy * dy)

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Do you currently have a team agreement?

Answered: 1 week ago