Question: Python code! Create an iterator whose constructor takes an integer (n) and a function (f) as argument and represents the sequence of the numbers f(n),f(n+1),f(n+2),.
Python code!
Create an iterator whose constructor takes an integer (n) and a function (f) as argument and represents the sequence of the numbers f(n),f(n+1),f(n+2),.
For example:
>>> squares = iterApply(1,lambda x: x**2)
>>> squares.__next__()
1
>>> squares.__next__()
4
>>> squares.__next__()
9
You can start with the following code:
class iterApply():
#write your code here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
