Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Do Parts a) , b)! Question 9 30 pts a programming pro one, up g on e wor ing s e signa e, parame
Please Do Parts a) , b)!
Question 9 30 pts a programming pro one, up g on e wor ing s e signa e, parame ive e namea oa To get credit for this problem the code must NOT use: for loops, while loops, functions from other modules, the filter function, or any library functions except type), len), and list slices A flat list has elements that are not lists themselves, while a nested list has some elements that are lists. E.g. [1,2,3] is a flat list, while [1, [[2], 3], 4] is a nested list. For this problem a list Ist is defined flat if for each element x in Ist, type(x)!- list. The empty list [] is considered to be flat. The flat version of [1, [[2], 3], 4] is [1, 2, 3, 4] a) Write a recursive function filterflatlst(lst, predicate) that takes as parameters a list Ist (assumed to be flat) and a function predicate and returns a list with the elements x from Ist for which predicate(x) returns True filterflatlst(l1, predicate) returns [], the empty listStep 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