Answered step by step
Verified Expert Solution
Link Copied!

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)!

image text in transcribed

image text in transcribed

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 list

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

4. Systematic use of measures of HRM.

Answered: 1 week ago