Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE WRITE IN SML pSumtoN -20% 6. grou groupSumtoN function takes two arguments where the first argument is an integer (N) and the second is

PLEASE WRITE IN SML

image text in transcribed

pSumtoN -20% 6. grou groupSumtoN function takes two arguments where the first argument is an integer (N) and the second is a list (L). The goal is to produce a result in which the elements of the original list have been collected into ordered sub-lists each containing maximum number of consecutive elements from L summing up to N or less (where N is the integer argument). The leftover elements (if there is any) are included as the last sub-list with a sum less than N. If an element in the input list L is greater than N that element should be included in its own sublist (including that element only) The type of groupSumtoN should be: int -> int 1list -> int list list Note: this function is not required to be tail-recursive Examples: groupSumtoN 15 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [[1,2,3,4,51,16,71, 181,191,[10]] >groupSumtoN 11 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [[1,2,3,41,15,61,171,181,191,110]] pSumtoN -20% 6. grou groupSumtoN function takes two arguments where the first argument is an integer (N) and the second is a list (L). The goal is to produce a result in which the elements of the original list have been collected into ordered sub-lists each containing maximum number of consecutive elements from L summing up to N or less (where N is the integer argument). The leftover elements (if there is any) are included as the last sub-list with a sum less than N. If an element in the input list L is greater than N that element should be included in its own sublist (including that element only) The type of groupSumtoN should be: int -> int 1list -> int list list Note: this function is not required to be tail-recursive Examples: groupSumtoN 15 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [[1,2,3,4,51,16,71, 181,191,[10]] >groupSumtoN 11 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [[1,2,3,41,15,61,171,181,191,110]]

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions