4 ms·
Don't let your dreams be dreams. https://coconut.readthedocs.io/en/master/DOCS.html#statement-lambdas https://coconut.readthedocs.io/en/master/DOCS.html#statem
by scoopertrooper 5y ago
Don't let your dreams be dreams.
https://coconut.readthedocs.io/en/master/DOCS.html#statement-lambdas https://coconut.readthedocs.io/en/master/DOCS.html#statement...
- revskill 5y agoThis is still 1 line, just separated by semicolon ?
- pansa2 5y agoAnd it only supports assignment statements and keyword statements. What’s a “keyword statement”?
- scoopertrooper 5y agoYou want lines, so that you may have multiple statements in your lambda. They've given you multiple statements, but using the semicolon instead. I appreciate that won't work well for all use cases, but it'd eliminate a lot of the pain with the current lambda implementation. For whatever reason, the Python community declared multiline lambdas as non-pythonic and this project aims to remain pythonic, so they went with semicolons instead. I'm not a Python developer myself, but if that was the only thing holding you back, then perhaps that reason is now slightly reduced?
- macintux 5y agoIt does seem that if a function can’t fit with this new expanded capability, it probably is complex enough to warrant a name. Assuming that Python’s support for nested functions carries over to Coconut, it seems like a reasonably-complete feature set.
- xaedes 5y agoIf you really need more than one line this will probably work: L |> map$(def (x) -> ( y = 1/x; y*(1 - y) )) You can also make multiline python lambdas by using brackets. That is if you can fit your code into an expression.