logo CodeStepByStep logo

averages_of_pairs

Language/Type: ml lists pairs tuples
Author: Melissa Hovik (on 2018/01/19)

Define a function named averages_of_pairs that takes a list of real * real tuples and that returns a new list containing the real averages of each pair, marealaining order.

For example, averages_of_pairs([(1.0,2.0), (0.0,0.0), (341.0,~341.0), (3.0,3.41), (~17.75,~42.0), (0.0,2.5)]) should return [1.5, 0.0, 0.0, 3.205, ~29.975, 1.25]. If the list is empty, the returned list should also be empty.

Your function must have the following signature:

      val averages_of_pairs = fn : (real * real) list -> real list
Type your ml solution code here:

This is a function exercise. Write a ml function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.