Are anonymous functions and lambda functions same? | Sololearn: Learn to code for FREE!

+13

Are anonymous functions and lambda functions same?

lambda functions seem to have lambda calculus related to them, while I didn't get any reference to lambda calculus when I learnt anonymous functions

6/5/2018 4:48:33 PM

DAB

9 Answers

New Answer

+9

Pretty much. It's taken from lambda calculus but in programming we use the term lambda pretty casually for anything that is (kind of) a function and (kind of) has no name. Javascript "lambdas" actually have a name. I present to you the useless (non-)lambda: let fn = function(){ return arguments.callee; }; fn()()()()()()()()()()()()()()()()()()(); `arguments.callee` will always return the function it sits in, thereby giving it a name! Still, it's lambda enough so we call it lambda. Before java got lambda-lambdas, people were calling anonymous subclasses "lambdas" too, probably because "anonymous subclass" is a mouthful. Of course it's not a function but a class, but whatever, it's lambda enough. Runnable x = new Runnable(){ public void run(){ ... } }; Other languages have pretty un-lambda lambdas too, but you get the idea. It's not an exact science, though maybe other people would disagree. (Although I can talk about lambda calculus and "real lambdas" if you want)

+3

1. Iam not sure 2. lambda is a shortcut to define functions. These functions has parameters and a return value but to assign a name to this function is optional. 3. I think anonymous functions are functions without name. This sounds maybe useless but when you have a function, which takes another function as parameter it is not necessary to assign a name to the function. syntax of lambda: fName=lambda params: retvalue https://code.sololearn.com/csNrZ7KPcU62/?ref=app

0

0

Too muct

0

yes

0

i think,yes.

0

0

0