Pretty cool, but why?
Pretty cool, but why?
Other urls found in this thread:
en.wikipedia.org
twitter.com
Metaprogramming on steroids
Because it's cool.
Ok, great. But WHEN do we require a nameless function?
I can't remember the exact uses, but you can use lambda as a sort key on Python. It's pretty convenient sometimes
it doesn't have to be nameless you can assign it to a variable
sorted() has a key parameter that takes an anonymous function and there are many other use cases after you finish your first year of programming I can show you
have you ever used a higher order function? or a callback function that's executed at the end of some other function? instead of defining a specialized function with a name which you'll never use again, just write it exactly where you need it without a name
If you can't instantly name like 10 uses of this you are not a fucking programmer. holy fuck this is one embarrassing thread, fucking day care.
If I’m using it once, why do I need a function in the first place, nameless or otherwise?
Who the fuck said I was a programmer you fucking retard? I am asking THE real questions and you bash them like a jew bashes any criticism of the holohoax narrative.
This isn't even a question in Lisp. Go find yourself a non-blub language and use that instead.
you can refer variables from the context where the lambda was defined
[1,2,3].map((input) => input * 2) ----> [2,4,6]
because functions are extremely useful for encapsulating functionality, even inside of other functions
>poltard is a retard
POTTERY
Writing Python code is a political statement.
polchomos BTFO
en.wikipedia.org
in this example the lamba is named, but it doesn't have to be.
so that you don't have to name it, and thus use it in-line
your pic nullifies the one thing that lambdas are useful for
Function parameters (callbacks, predicates, body for mapping or just when you need an action/behavior as a parameter) and local variables storing private jumbled five liners never to be used again behind a meaningful name.
+ you can make an associative container for a key/behavior and write a function which goes through this container calling the stored function for a key + whatever you passed to the iterating function.
I dunno bros not an expert in this stuff.
>GUYS THEY ADDED LAMBDAS TO PYTHON DO YOU KNOW WHAT CODING A LAMBDA IS