magic-sudo
magic-sudo

Reputation: 1246

Is lambda function in C language

Is in C language lambda function or I have to write it by my own. I was searching on internet and haven't find anything only C++ and C#.

Upvotes: 1

Views: 412

Answers (1)

Jack
Jack

Reputation: 133609

In the theoretical sense is not a lambda language because you don't have a true lambda type which is able to be passed around and behaves itself like a real value.

But with function pointers you can obtain pretty similar results:

typedef int (*lambda)(); // defines lambda as a type which is a pointer to a function that returns an int

int foo() { return 5; }
int bar() { return 10; }

lambda function;
function = foo;
function = bar;

int result = function();

Upvotes: 3

Related Questions