Question: In Python, write a function filterArray. This takes a function p and an array t. Function p can be assumed to be a one-parameter function

In Python, write a function filterArray. This takes a function p and an array t. Function p can be assumed to be a one-parameter function that will accept any value in array t. filterArray returns an array containing every value v in t for which p(v) is truthy, in the same order as they appear in t. No other key-value pairs should appear.

Example:

function isBig(n) return n > 6 end arr = { 1, 7, 9, 3, 10, 6, 2, 7, 0 } arr2 = filterArray(isBig, arr) # arr2 should be the array { 7, 9, 10, 7 }.

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!