What-is-LAMBDA?
| Part | Function | Lambda |
|---|---|---|
| Header | def square_x (x) | lambda x |
| Split by | : and move to next line |
: stay in-line as single line expression |
| Body | return x * x | x * x |
| Run | square_x(3) | only put arguments end of lambda expression like this -> (3) |
Next we try to do more examples using a table to split each of the compartment that tell the difference between function and lambda
| Part | Function | Lambda |
|---|---|---|
| Header | def sum_square (x, y, z) | lambda x, y, z |
| Split by | : and move to next line |
: and stay in-line as single line expression |
| Body | return (x x) + (y y) + (z * z) | (x x) + (y y) + (z * z) |
| Run | sum_square(3, 4, 5) | only put arguments end of lambda expression like this -> (3, 4, 5) |
Can you tell the diference between function and lambda using these two examples?