Thursday, January 19, 2006
Lambda Fun
Coming from my liberal arts background, I never learned Lisp or Scheme in college. So the anonymous Lambda function in Python always escaped me. As a baby Pythonista, this was rather humiliating. So when I finally grokked it after way too much effort, it was like my brain exploded. In essence, the problem was that I thought about it too hard, when in reality, the lambda capability of Python, Lisp, Scheme, et al is actually a simple concept.
So now, of course, I've been trying to figure out how to make it work in ColdFusion. The problem, alas, is that to make it work I would have to return a function from the lambda function. And that just isn't possible. So what about returning a new object? Of course, that would destroy the beautful elegance I get in python via:
f = lamba x, y, z: x + y+ z
f(2, 3, 4)
Result : 9
Instead, in ColdFusion I could code something like:
f = lamba("x, y, z : x + y+ z");
f.lambda(2, 3, 4);
Result: 9
Basically, the ColdFusion method would be turning the nice, elegant Python function into a object factory. Now I have no problem with object factories, but is this really the way to go?
I don't know. I am wondering if doing a Lambda function is sheer overkill in CFMX.
Coming from my liberal arts background, I never learned Lisp or Scheme in college. So the anonymous Lambda function in Python always escaped me. As a baby Pythonista, this was rather humiliating. So when I finally grokked it after way too much effort, it was like my brain exploded. In essence, the problem was that I thought about it too hard, when in reality, the lambda capability of Python, Lisp, Scheme, et al is actually a simple concept.
So now, of course, I've been trying to figure out how to make it work in ColdFusion. The problem, alas, is that to make it work I would have to return a function from the lambda function. And that just isn't possible. So what about returning a new object? Of course, that would destroy the beautful elegance I get in python via:
f = lamba x, y, z: x + y+ z
f(2, 3, 4)
Result : 9
Instead, in ColdFusion I could code something like:
f = lamba("x, y, z : x + y+ z");
f.lambda(2, 3, 4);
Result: 9
Basically, the ColdFusion method would be turning the nice, elegant Python function into a object factory. Now I have no problem with object factories, but is this really the way to go?
I don't know. I am wondering if doing a Lambda function is sheer overkill in CFMX.
Comments:
<< Home
A lambda function is feasible for flexibility. It's not only a matter of syntax format. For example, for a function (\x . \y . x + y), it will sum up two numbers x and y when both arguments are given. And it may become a partial function when it accepts only the argument x. Thus, on customizing CF lambda function, it's a matter of how to represent a lambda function as a structure which may contain another lambda function.
Post a Comment
<< Home