Since (?:ECMA|Java)script supports closures, it is Lambda-calculus ready. I googled examples but there seems none so I made one.
Welcome to the world of λ!
// define
var zero = function(f){
return function(x){
return x}};
var succ = function(n){
return function(f){
return function(x){
return f(n(f)(x))}}};
var add = function(m){
return function(n){
return function(f){
return function(x){
return m(f)(n(f)(x))}}}};
var mul = function(m){
return function(n){
return function(f){
return m(n(f))}}};
var pow = function(m){
return function(n){
return n(m)}};
// execute
function $(id){ return document.getElementById(id) };
var one = succ(zero);
var two = succ(one);
var four = add(two)(two);
var eight = mul(two)(four);
var sixteen = pow(two)(four);
var numbers = [one, two, four, eight, sixteen];
$('result').innerHTML = '';
for (var i = 0; i < numbers.length; i++){
var n = numbers[i];
$('result').innerHTML += numbers[i](function(n){return 1+n})(0);
$('result').innerHTML += ' = ';
$('result').innerHTML += numbers[i](function(n){return '(1+' + n + ')'})(0);
$('result').innerHTML += '<br />';
}
Show me!
Also note that this example contains no <script> tag but the "Show Me!" still works. Trick? onclick="eval(document.getElementById('lambda').firstChild.nodeValue)".
Don't you love dynamic lanugages?
Dan the (?:ECMA|Java)scripting Lambacamel
Managed Hosting, Colocation and Data Center Services by victoryushchenkonashpresudent ...
Posted by: Robert | Friday, 27 July 2007 at 07:43
The Iraqi government says guards from US security firm Blackwater killed more people than previously thought.
Posted by: Maxim | Tuesday, 09 October 2007 at 12:41
Good news!
Posted by: BRADLEY Elijah | Friday, 12 October 2007 at 08:57
bla
Posted by: bla | Thursday, 13 December 2007 at 07:22
H!, nice day, look this:
Netvouz is a social bookmark manager where you can store your favorite links online and access them from any computer.
End ^) See you
Posted by: DEREK Flo | Friday, 08 February 2008 at 06:02
Hello,
Not sure that this is true) but thanks
Have a nice day
Hobosic
Posted by: Hobosic | Thursday, 05 February 2009 at 16:39
Thank for sharing the great script :-)
Posted by: work at home | Wednesday, 25 March 2009 at 10:46
thanks for sharing the great script.
Posted by: work at home | Wednesday, 25 March 2009 at 10:48
Hi, It's the second time i'm posting you without a reply. I found your site using Yaehoo, does your site support firefox?
Posted by: Yaehoo | Friday, 01 May 2009 at 11:48
Hi, It's the second time i'm posting you without a reply. I found your site using Yaehoo, does your site support firefox?
Posted by: Yaehoo | Friday, 01 May 2009 at 11:48
rmgnHh viTwQ937Baww5mLp1oWxu
Posted by: molly | Tuesday, 18 August 2009 at 17:17
Well, the most astonishing fact is the script-less approach.
Posted by: evalinux.wordpress.com | Tuesday, 15 September 2009 at 14:48
Why stop with Church numerals?
You can do the Y combinator:
http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/
Now you don't need recursion or loops!
Posted by: Matt Might | Sunday, 20 September 2009 at 12:29