It's easy to get intimidated by a feature like Lambda Expressions. It has a Greek word in it, so it must be difficult, right? And you can read explanations like this:

Lambda expressions, one of the most important new features to be included in the next 3.0 version of C# and one that offers support needed by the LINQ Project, are precisely a feature coming from the world of functional programming. ... Scheme ... Lisp ...

Or this summary:

In mathematical logic and computer science, lambda calculus, also λ-calculus, is a formal system designed to investigate function definition, function application, and recursion. It was introduced by Alonzo Church and Stephen Cole Kleene in the 1930s; Church used lambda calculus in 1936 to give a negative answer to the Entscheidungsproblem. Lambda calculus can be used to define what a computable function is. The question of whether two lambda calculus expressions are equivalent cannot be solved by a general algorithm. This was the first question, even before the halting problem, for which undecidability could be proved. Lambda calculus has greatly influenced functional programming languages, such as Lisp, ML and Haskell.

Lambda calculus can be called the smallest universal programming language. It consists of a single transformation rule (variable substitution) and a single function definition scheme. Lambda calculus is universal in the sense that any computable function can be expressed and evaluated using this formalism. It is thus equivalent to the Turing machine formalism. However, lambda calculus emphasizes the use of transformation rules, and does not care about the actual machine implementing them. It is an approach more related to software than to hardware.

This sounds really difficult. So let me show you something that's not difficult at all:

<input type=button value="Try it now" onClick="alert('Hello from JavaScript!')">

You know what that does, right? Well the stuff after onClick=" and before "> is [gasp!] a Lambda Expression. It's a little piece of code that you can stick somewhere without a whole lot of defining a function and defining a delegate and pointing that delegate at that function and blah blah blah. You can stick two lines of JavaScript in there if you want:

<INPUT TYPE="radio" VALUE="Switching to Blue" onClick="alert(value);document.bgColor='blue'">

This feels natural and ordinary in JavaScript, and all folks are talking about is giving you that same freedom in strongly typed languages where the compiler is your friend. We have some of this in C# 2.0 with anonymous methods, but lambda expressions are in effect more strongly typed. Here's a nice explanation of the subtle distinction.

It's not actually that intimidating at all ... it's going to make life easier.

Kate

Theme design by Bryan Bell

newtelligence dasBlog 2.3.9074.18820

| Page rendered at Friday, March 01, 2024 10:43:52 AM (Eastern Standard Time, UTC-05:00)