Hi, I'm trying to write a function that takes in as arguments a procedure with one argument and an integer. The integer represents how many times the procedure will execute on the argument.
This is what I had in mind... I had q = q + compose(p,p) but it tells me it can't add a function and an integer. Which I see. But when I have what's written above, it returns the value of q and not a memory location.
I'm a brand new programmer... Any ideas would be greatly appreciated.
Code:
def compose(f,g):
return lambda x: f(g(x))
def repeatedlyApply (p,n):
i=0
q=0
while (i<n):
q = compose(p,p)
i=i+2
return q
I'm a brand new programmer... Any ideas would be greatly appreciated.
Comment