Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Haskell group_sum function takes two arguments where the first argument is a list (1st) and the second argument is an integer (n). The

Please use Haskell

image text in transcribedimage text in transcribed

group_sum function takes two arguments where the first argument is a list (1st) and the second argument is an integer (n). 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 lst summing up to or less than n2k (where is k the group number starting at 0 , i.e., k=0,1,2,3,4.). The leftover elements (if there are any) are included in the last sub-list with a sum less than n2k. When elements are added to the groups, if the next element in the input list (13t) is greater than n2k, the group will be empty list [ ]. Examples: group_sum [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]10 [[1,2,3,4],[5,6,7],[8,9,10,11],[12,13,14,15,16],[17]] > group_sum [12,10,1,3,4,7,11,22,2,5,40,100,4]10 [[],[12],[10,1,3,4,7,11],[22,2,5,40],[100,4]] > group_sum [5,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20]4 [[],[5,2,3,4,5,6],[7,8],[9,10,11],[12,13,14,15,16,20] > group_sum [] 3 []

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions