可能重複:
What is a lambda and what is an example implementation?請解釋拉姆達運作
下面是一個lambda代碼(在Python的字節):
def make_repeater(n):
return lambda s: s * n
twice = make_repeater(2)
print twice('word')
print twice(5)
的輸出是這:
wordword
10
有人可以解釋lambda如何在longform中工作嗎? lambda函數中word
和5
如何傳遞給s
?
謝謝。
不錯的工作要求比「可能的重複」問題更好的問題,但第一個答案非常棒。 – sarnold 2011-12-30 23:44:56
我想我會得到一個心理堆棧溢出錯誤從遞歸到重複的問題... – FakeRainBrigand 2011-12-30 23:47:35
請參閱[理解-python中的lambda函數](http://stackoverflow.com/questions/17833228/understanding-lambda-功能?LQ = 1) – nawfal 2014-07-04 06:09:31