Question: Please solve this in the OCaml programming language. We are given this as a helper function that we must use for part b: exception NotImplemented;;

 Please solve this in the OCaml programming language. We are giventhis as a helper function that we must use for part b:

Please solve this in the OCaml programming language. We are given this as a helper function that we must use for part b:

exception NotImplemented;; let rec sumlist l = match l with | [] -> 0.0 | x :: xs -> x +. sumlist xs ;;

Q1 (a). [10 points] In this question you will write a program that takes two lists of the same length and returns a single list with the items paired together. This will be used in later questions in this assignment; we will need it with floating point items but your code should be polymorphic. The snippet below shows the function name, which you must use, and the type returned by the OCaml system. Your code must have this type. # let rec pairlists twolists -... val pairlists : 'a list * 'b list -> ('a * 'b) list - We will forbid the use of the List.combine library function that does the same thing. Test inputs are two int lists of the same length and we will check that you have handled the case of empty input lists. Here is an example showing the right way and the wrong way to use pairlists. # let 11- [1:23];; val 11 : int list-[1; 2; 3] val 12 : char list = [a'; 'b'; ' c' ] # let pi -pari ists (11,12) ;; val pl : (int * char) list = [(1, 'a'): (2, 'b'); (3, ,c')] # let e1 = pairlists 11 12; ; Characters 9-18: let e1 - pairlists 11 12;; Error: This function has type 'a list * 'b list -> ('a * 'b) list It is applied to too many arguments; maybe you forgot a ; Q1 (a). [10 points] In this question you will write a program that takes two lists of the same length and returns a single list with the items paired together. This will be used in later questions in this assignment; we will need it with floating point items but your code should be polymorphic. The snippet below shows the function name, which you must use, and the type returned by the OCaml system. Your code must have this type. # let rec pairlists twolists -... val pairlists : 'a list * 'b list -> ('a * 'b) list - We will forbid the use of the List.combine library function that does the same thing. Test inputs are two int lists of the same length and we will check that you have handled the case of empty input lists. Here is an example showing the right way and the wrong way to use pairlists. # let 11- [1:23];; val 11 : int list-[1; 2; 3] val 12 : char list = [a'; 'b'; ' c' ] # let pi -pari ists (11,12) ;; val pl : (int * char) list = [(1, 'a'): (2, 'b'); (3, ,c')] # let e1 = pairlists 11 12; ; Characters 9-18: let e1 - pairlists 11 12;; Error: This function has type 'a list * 'b list -> ('a * 'b) list It is applied to too many arguments; maybe you forgot a

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!