
Oct. 4, 2021
4:34 a.m.
Abdulla Al Kathiri wrote:
Oh I forgot what if you want to return a set from your lambda? Maybe a lambda set should at least have one assignment statement to qualify it as one. Expressions only inside a set syntax will be just a normal set that doesn’t care about order as you pointed out. But a lambda set will care about the order just like when you do a normal multi-lines def function. def f(x): print(x) z = x + 3 return z Is equivalent to (x) => {print(x), z = x + 3, z}
You can achieve this already with tuples and assignment expressions (not very readable though): lambda x: (print(x), z := x+3, z)[-1]