Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 implementationStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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