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

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!