For a person without a comp-sci background, what is a lambda in the world of Computer Science?
The name "lambda" is just a historical artifact. All we're talking about is an expression whose value is a function.
A simple example (using Scala for the next line) is:
args.foreach(arg => println(arg))
where the argument to the foreach
method is an expression for an anonymous function. The above line is more or less the same as writing something like this (not quite real code, but you'll get the idea):
void printThat(Object that) {
println(that)
}
...
args.foreach(printThat)
except that you don't need to bother with:
Once you're used to function values, having to do without them seems as silly as being required to name every expression, such as:
int tempVar = 2 * a + b
...
println(tempVar)
instead of just writing the expression where you need it:
println(2 * a + b)
The exact notation varies from language to language; Greek isn't always required! ;-)