Reference no: EM132262902
Programming Languages Assignment: two small F# functions
Overview - In this assignment write 2 small functions involving tuples; you can solve using recursion, higher-order, or both. The exercise is setup on Codio, but you can work in whatever environment you prefer. Regardless of where you work, be sure to submit the two functions separately as described in the next section.
Exercises -
Exercise 1: examAverages LT
Given a list of tuples of the form ("netid", [score;score;score;...]), computes each netid's average score as a real number and returns a list of tuples of the form ("netid", average).
NOTE: F# offers a function List.average L that computes the average of a list of real numbers. However, the list of scores in the tuple are integers, so in order to use List.average, you would first need to convert the integers to reals --- List.map float L would work nicely here.
You can solve using recursion, or higher-order, or both; tail recursion is not necessary.
Write the required function, using whatever approach you prefer. To test your work, open a terminal window and load the file into F# interactive like we did in the previous homeworks. [If you need an example of using F# interactive, please see page 2 of the HW #08 handout.]
Exercise 2: pairwise L1 L2
Edit the file "hw1002.fs". Read the comments, implement as you see fit, test using F# interactive.
Given 2 lists L1 and L2, both the same length, merges the corresponding elements into pairs, returning a list of pairs.
You can solve using recursion, or higher-order, or both; tail recursion is not necessary.
Attachment:- Assignment Files.rar