Lambda Programming Language


Here is a definition of a lambda language from a discussion in stackoverflow.com: “A lambda language, is a language that allows passing a function to another function, where the function is treated as any other variable.” Below is some code from that same discussion.

function applyOperation(a, b, operation) {
  return operation(a,b);
}

function add(a,b) { return a+ b; }
function subtract(a,b) {return a - b;}

and can be called like
applyOperation(1,2, add);
applyOperation(4,5, subtract);
// anonymous inline function
applyOperation(4,7, function(a,b) {return a * b})

The reason we are discussing this is because JavaScript is a lambda language.

Wikipedia describes first-class functions this way: “In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures”.

Leave a comment

Your email address will not be published. Required fields are marked *