+ 6

I need help understanding this example from w3Schools about using Lambdas.

Hello, I need help understanding this code from w3schools about lambdas. I'm mainly confused on which argument is being sent to which parameter. https://code.sololearn.com/c6M7D403nfiA/?ref=app

13th Jun 2020, 3:03 PM
Raul Sanchez
Raul Sanchez - avatar
8 odpowiedzi
13th Jun 2020, 4:10 PM
Oma Falk
Oma Falk - avatar
+ 2
Rithea Sreng Oma Falk Bilbo Baggins Thanks, I wanted to write down the steps to make sure what was going on line by line. Let me know if I made any mistake. https://code.sololearn.com/c12uDWhYc2Y8/?ref=app
13th Jun 2020, 5:59 PM
Raul Sanchez
Raul Sanchez - avatar
13th Jun 2020, 3:30 PM
JaScript
JaScript - avatar
+ 1
Ja Play Thanks for the link explaining a bit more on lambas. However, SoloLearn just has examples of taking 1 argument. The example from w3schools takes in multiple arguments which is a bit confusing for me to understand.
13th Jun 2020, 3:49 PM
Raul Sanchez
Raul Sanchez - avatar
+ 1
Also our lambda has just one argument, "a". But it has also an unknown variable, "n", passed by function myfunc() So mydoubler = myfunc(2) can be replaced with def mydoubler: return lambda a : a * 2 or even, instantiating the lambda, def mydoubler(a): return a*2
13th Jun 2020, 4:17 PM
Bilbo Baggins
Bilbo Baggins - avatar
0
lambda is an anonymous function
14th Jun 2020, 1:06 AM
UwU
UwU - avatar