Line 1 defines an
Adder
that returns another function with X
bound to the input to Adder
. In line 2 we create a specific adder - in this case a function that adds 10 to its input. I think line 3 was meant to show how the specific adder created in line 2 could be invoked. If Adder10
were to be called with 5 as argument it would return 15. Instead Adder
is invoked again and the result shown is not correct as Adder(10)
would return a generator, not 15.
I think the snippet can be modified thus:
No comments:
Post a Comment