2 ms·
You can't define a function via 'def' and pass it as an argument at the same time. You can do it via 'lambda' though (which doesn't require any indentation sinc
by aldanor 8y ago
You can't define a function via 'def' and pass it as an argument at the same time. You can do it via 'lambda' though (which doesn't require any indentation since it's just an expression), what's the problem with it?
>>> (lambda f: lambda x: f(x) * 2)(lambda x: x + 1)(100)
202
- amelius 8y agoSo the problem is that you can only inline expressions; you can't inline let-blocks (assignments), or multiple statements. The usefulness is very limited.