Question: Exercises should be completed using the OCaml programming language with code presented Each exercise below requires you to implement a single function. Unless explicitly mentioned,

Exercises should be completed using the OCaml programming language with code presented

 Exercises should be completed using the OCaml programming language with code

Each exercise below requires you to implement a single function. Unless explicitly mentioned, you should not use any built-in functions or special forms If you wish, however, you may implement additional helper functions on top of the required ones. Note that some exercises specify whether your solution should be tail-recursive (or not). If unspecified, you may do either. 2. poly_eval: Given coeffs and x, where coeffs is a list of integer coefficients (a,b,c,) and x is an integer, computes the value of the polynomial ax0+bx1+cx2+ E.g., # poly_eval [2;3;4]2;; - : int =24 # poly_eval [] 10;; - : int =0 # poly_eval [8;4;2;1]4;; - : int =120 Your implementation should be tail-recursive. You may use iexpt from the previous exercise. 3. concatenate : Given a list of lists, concatenates all the elements of the argument lists into a single list. E.g., \# concatenate [[1;2;3];[4];[5;6]]; - : int list =[1;2;3;4;5;6] \# concatenate [[ 'h'; 'e' ];[1];[];[1 '; 'o' ]]; - : char list =[ 'h'; 'e'; 'l'; 1;0] Your implementation should be tail-recursive. Additionally, when building your result list, you should only use cons (:: ), and your implementation should have linear runtime w.r.t. the total number of elements. Hint: it might be helpful to use List. rev at some point in your implementation

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!