Question: Programming Language: OCaml In OCaml, write a function point_distance that takes two points, and computes their distance (As a hint think of the hypotenuse). This

Programming Language: OCaml

In OCaml, write a function point_distance that takes two points, and computes their distance (As a hint think of the hypotenuse).

This is what I have done so far:

type point2d = Point of float * float;; let origin = Point (0.0, 0.0);;

let point_distance point2da = match point2da with | Point(a,b) -> sqrt((a *. a ) +. (b *. b));;

let point_distance point2dc = match point2dc with | Point(c,d) -> sqrt((c *. c ) +. (d *. d));;

let point_distance hypo = match hypo with | Point (a,b), (c,d) -> sqrt((c -. a ) +. (d -. b));;

print_float (point_distance origin);; print_string ;;

exit 0;;

Please show how to fix it. Thanks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!