Question: So far this semester, we have written sever al functions which find the nth number in a seqence which satisfies some property (e g. the

So far this semester, we have written sever al functions which find the nth number in a seqence which satisfies some property (e g. the nth even number) It would be helpful if we wrote a higher order function which could take a function which generated the sequence and a function which tested for the property in which we are interested as well as the integer n and returned the nth value in that sequence which satisfied the property (i.e. the test function returns true when passed that value) (a) Write a function, named find, which takes three parameters (sequence, a function; test a function and n, a positive integer) and returns the nth value in sequence for which the test function returns true (R) when passed a value in sequence. (sequence k) should return the kth element of the sequence. (test x) should return #t if the property holds for x. #f otherwise. So far this semester, we have written sever al functions which find the nth number in a seqence which satisfies some property (e g. the nth even number) It would be helpful if we wrote a higher order function which could take a function which generated the sequence and a function which tested for the property in which we are interested as well as the integer n and returned the nth value in that sequence which satisfied the property (i.e. the test function returns true when passed that value) (a) Write a function, named find, which takes three parameters (sequence, a function; test a function and n, a positive integer) and returns the nth value in sequence for which the test function returns true (R) when passed a value in sequence. (sequence k) should return the kth element of the sequence. (test x) should return #t if the property holds for x. #f otherwise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
