Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What is the role of the Joint Commission in health care?

Answered: 1 week ago