Question: 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) NONE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
