3 ms·
in principle you could always write one-liners like this with lambdas or list comprehensions by translating let x = <val> in <expr> into this: (lambda x:
by uryga 7y ago
in principle you could always write one-liners like this with lambdas or list comprehensions by translating
let x = <val> in <expr>
into this:
(lambda x: <expr>)(<val>)
(as the lambda calculus does)
or this:
[<expr> for x in (<val>,)][0]
of course the readability is terrible, but the power was always there if you wanted to (ab)use it :)
(yeah, i've used the second one in a repl, don't @ me)
- recursivecaveat 7y agoIndeed, a single python expression has been enough for Turing completeness for a long time now. I wrote a brainfuck interpreter in one once.