Author after author keeps referring to the tenor of elegance and simplicity of functional coding (e.g. lambda, Scheme, Lisp). I just read
this intro which, using metaphor, shed some light, but I still don't get it. Does the following excerpt jive with anyone?
QUOTE
Functions and Lambda Notation
A function accepts input and produces an output. Suppose we have a "chocolate-covering" function that produces the following outputs for the corresponding inputs:
peanuts -> chocolate-covered peanuts
rasins -> chocolate-covered rasins
ants -> chocolate-covered ants
We can use Lambda-calculus to describe such a function:
Lx.chocolate-covered x
This is called a lambda-expression. (Here the "L" is supposed to be a lowercase Greek "lambda" character).
If we want to apply the function to an argument, we use the following syntax:
(Lx.chocolate-covered x)peanuts -> chocolate-covered peanuts
Functions can also be the result of applying a lambda-expression, as with this "covering function maker":
Ly.Lx.y-covered x
We can use this to create a caramel-covering function:
(Ly.Lx.y-covered x)caramel -> Lx.caramel-covered x
(Lx.caramel-covered x)peanuts -> caramel-covered peanuts
Functions can also be the inputs to other functions, as with this "apply-to-ants" function:
Lf.(f)ants
We can feed the chocolate-covering function to the "apply-to-ants" function:
(Lf.(f)ants)Lx.chocolate-covered x
-> (Lx.chocolate-covered x)ants
-> chocolate-covered ants
The key is in that quote somewhere, I know it. I got lost when the author merged lambda syntax with algebraic syntax in the "apply to ants" function:
Lf.(f)ants. I was doing great until the end there.
I'm on day-4 and going nuts. I hate not understanding something, especially given that I do understand
recursion, its mathematical equivalent. It seems that I should be able to intuit Lambda but that insight just ain't coming along.
This post has been edited by LowWaterMark: 14 Oct, 2008 - 01:28 AM