Question: /* TASK 4 (7.5pts): Similar to filter we have another function called partition. This function partitions a list into 2 separate partitions based on a

/* TASK 4 (7.5pts): Similar to filter we have another function called partition. This function partitions a list into 2 separate partitions based on a predicate function. Specifically, partition takes 2 arguments: 1. g - This function decides which partition an element of the list falls into If the function returns true, then it goes into the left partition, otherwise it goes into the right partition. 2. ls - This is the list that is to be partitioned. Some examples of partition are: partition((x) => x <= 2, List([1,2,3,4])) ------> List([List([1,2]), List([3,4])]) partition((x) => x % 2 == 0, List([1,2,3,4])) ------> List([List([2,4]), List([1,3])]) For this task, your constraint is to write this function using filter. You are not allowed to use other looping constructs, even fold_left. */ const partition = (g, ls) => /** **/ undefined; /** **/

PLS HELP

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!