i m new to programming but im stuck with a question, which im asking myself. I made an example like this:
u = 1
def method1(x):
def method2(n):
def method3(m):
return x + n + m
def method4():
global u
u += 1
method4()
return method3
def method5(y):
return x + y
return method2, method5
The question is: Can I replace some of these defintions with lambda expressions? I dont want to change the semantics of the code above. I was thinking about something like this:
u = 1
def method1(x):
def method2(n):
lambda m: x + n + m
def method4():
global u
u += 1
method4()
lambda y: x + y
return method2
If this what i have done is correct, can i replace even more definitions without changing the semantics of the code or am I wrong?