Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Kindly solve it in SML programming language. 1. Write a recursive ML function using pattern matching with name/type fill:intintintintlist that inputs an integer x, an
Kindly solve it in SML programming language.
1. Write a recursive ML function using pattern matching with name/type fill:intintintintlist that inputs an integer x, an integer s, and a non-negative integer n. It will return the list [x,x+s, x+2s,x+3s,,x+(n1)s] where the list starts with the value x and then each successive value adds s to the previous value until there are n values in the list. (You may assume valid inputs.) For example, - fill (1,3,7); val it =[1,4,7,10,13,16,19] : int list - fill (0,10,5); val it =[0,10,20,30,40] : int list 2. Write an ML accumulation function with name and type h:intintint that will be used with one of the reduce functions so that it will return the largest integer in a list of positive integers. For example: -foldlh?[2,8,5,1,7,6];valit=8:int In addition to submitting the code for h, submit the test case above with an appropriate initial value to demonstrate that your accumulation function produces the correctStep 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