4 ms·
I think if you really tried you could make it work but there are a lot of ugly and unique tradeoffs to work through. Something like this could work: foo((lam
by shrimpx 4y ago
I think if you really tried you could make it work but there are a lot of ugly and unique tradeoffs to work through. Something like this could work:
foo((lambda x, y:
for i in range(x):
y += i
return y),
20
)
- kazinator 4y agoIt could work like this: foo (lambda x, y::, 20) # :: means body of lambda follows :: # optional, if there is only one lambda and line has no argument lines for i in range (x): y += i return y The lambda bodies immediately follow the line. If the line has arguments, those follow the lambdas: if foo(lambda x::, list) < bar(lambda y::, list): :: # lambda x return x + x :: # lambda y return 2 * y return list # then statement of if
- kazinator 4y agoThe def keyword followed by a colon could be used as the marker for the continuation material that supplies the multi-line lambada bodies. Perhaps the double colon would be unnecessary: just make the expression optional, and if it's missing then there has to be an "outboard" body. if foo(lambda x:, list) < bar(lambda y:, list): def: # lambda x return x + x def: # lambda y return 2 * y return list # then statement of if