Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
frenchyatwork
5y ago
0 comments
Share
I'm sure there are cases where multiple lines would be nice, but I don't think this is one. This seems easier to read to me:
lambda i: -i * i if i < 0 else i * i
Also, the functional way of doing multiple lines in a lot of situations would typically be to compose smaller lambdas.
0 comments
default
newest
oldest
saghm
5y ago
Yeah, this is a trivial example. I picked it specifically to show that multi-line lambdas don't have to be stateful, not as an example of a lambda that couldn't be written in one line.
entha_saava
5y ago
And there is math.copysign
j
/
k
navigate · click thread line to collapse