Use ML Exercise 4 Write a function min3 of type int int in

Use ML

Exercise 4 Write a function min3 of type int * int * int -> int that returns the smallest of three integers.

Solution

Write a function min3 of type int * int * int -> int that returns the smallest of three integers.

fun min3 (a, b, c) =

if a < b andalso a < c

then a

else if b<a andalso b<c

then b

else c;

min3(2, 3, 1);

min3(1, 2, 3);

min3(2, 1, 3);

min3(~1, ~2, ~3);

Use ML Exercise 4 Write a function min3 of type int * int * int -> int that returns the smallest of three integers.SolutionWrite a function min3 of type int

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site