+ 14
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
9 ответов
+ 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
most
0
Too muct
0
yes
0
i think,yes.
0
yes
0
Yes.
0
Yess