Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve both parts: Part 1: Part 2: Given the pseudocode below, after it runs, result will be a list of numbers. What is the
Please solve both parts:
Part 1:
Part 2:
Given the pseudocode below, after it runs, "result" will be a list of numbers. What is the sum of the "result" list of numbers? (enter a number). E.g., if the result list equals [10,5] the sum would be 15 . / *Assume we are given three functions: map(array, mapFct) - returns new array with new elements produced by applying each existing element to mapFct select(array, selectFct) - returns new array containing elems in passed "array" where selectFct returns true (with elem as argument to fct) reject(array, rejectFct) - returns new array which is passed "array" with elems rejected where rejectFct returns true (with elem as argument to fct)*/ var elems, incrementFct, isGreaterThan1oFct, isEvenFct, isDivisibleByThreeFct, result; elems =[0,1,2,3,4,5,6,7,8,9,10 11,12,13,14,15,16,17,18,19] incrementFct =(x)=>x+1 isEvenFct =(x)=>x%2=0 isGreaterThan1oFct =(x)=>x>10 isDivisibleByThreeFct =(x)=>x%3==0 //e.g., divisible by three: 3,6,9, result = map(elems, incrementFct ) result = select(result, isEvenFct) result = select(result, isGreaterThan1oFct ) result = reject(result, isDivisibleByThreeFct) Given the pseudocode below, after it runs, "result" will be a list of numbers. What is the sum of the "result" list of numbers? (enter a number). E.g., if the result list equals [10,5] the sum would be 15 . /*Assume we are given three functions: map(array, mapFct) - returns new array with new elements produced by applying each existing element to mapFct select(array, selectFct) - returns new array containing elems in passed "array" where selectFct returns true (with elem as argument to fct) reject(array, rejectFct) - returns new array which is passed "array" with elems rejected where rejectFct returns true (with elem as argument to fct)*/ var elems, incrementFct, isGreaterThan1oFct, isEvenFct, isDivisibleBy ThreeFct, result; elems =[0,1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19] incrementFct =(x)=>x+1 isEvenFct =(x)=>x%2==0 isGreaterThan10Fct =(x)=>x>10 isDivisibleByThreeFct =(x)=>x%3==0 //e.g., divisible by three: 3,6,9, resultresultresultresult=map(elems,incrementFct)=reject(result,isEvenFct)=reject(result,isGreaterThan1oFct)=select(result,isDivisibleByThreeFct)Step 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