Question
a. Write a function maxVolume that takes a list of floating-point tuples that represent dimensions of a cube (length, width, and height) and returns the
a. Write a function maxVolume that takes a list of floating-point tuples that represent dimensions of a cube (length, width, and height) and returns the volume of the cube that has the largest volume. Each tuple has three floating point values that are all greater than zero. The volume of the cube is computed using (length*width*height). If the list is empty, return 0.0
Examples in F# Interactive:
> maxVolume [(1.1, 1.4, 1.8); (7.7, 2.8, 3.2); (9.9, 6.7, 1.0); (3.2, 5.4, 10.9)];; val it : float = 188.352 > maxCubeVolume [(0.33, 0.66, 2.75)];; val it : float = 0.59895 > maxCubeVolume [];; val it : float = 0.0
b. Write an function coupleThem that takes a string and a list of tuples as arguments. Each element of the list will be a tuple consisting of a string and an int. Find all of the tuples for which the string match the first argument and collect all of the corresponding integers. The final result should be the collected integers sorted in ascending order. For example, if the string argument is "A" and the list is [], your function should return the list [0;5]. You may use the List.sort function to produce your final result.
Examples in F# Interactive:
> coupleThem "A" [("A",5); ("BB",6); ("AA",9); ("A",0)];; val it : int list = [0; 5] > coupleThem "BB" [("A",5); ("BB",6); ("AA",9); ("A",0)];; val it : int list = [6] > coupleThem "X" [("A",5); ("BB",6); ("AA",9); ("A",0)];; val it : int list = [] > coupleThem "A" [];; val it : int list = []
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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