Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Standard ML language to solve the problem using RECURSIVE definitions . 4. Write a function reach sum that takes an int (x : int)
Using Standard ML language to solve the problem using RECURSIVE definitions.
4. Write a function reach sum that takes an int (x : int) as the sum, which must be positive, and an int list (xs : int list) of positive numbers. You should return an int (n: int) such that the sum of the first n elements is less than or equal x but the sum of the first n+1 elements is greater than x. Take into account the case where the sum of the entire list is less than x; your function may return NONE for such lists and return SOME n for lists sum to more than x. For exanuplc, reach_sum ([12, 27, 13, 10],40)> SOME 2 reach sum (12, 27,13, 10110) NONEStep 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