X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;ds=inline;f=lambda_evaluator.mdwn;h=7a037d591b7062f4256ee9f05f824aaabe469b0f;hb=5cee435609818dc6249d7f6299924b74157be0f9;hp=3240839ad8d8a337e692e6b989f6f693cbbbf774;hpb=fab4a757fb9854112b98a76671825847cadb2374;p=lambda.git
diff --git a/lambda_evaluator.mdwn b/lambda_evaluator.mdwn
index 3240839a..7a037d59 100644
--- a/lambda_evaluator.mdwn
+++ b/lambda_evaluator.mdwn
@@ -22,7 +22,7 @@ Blank lines are fine.
*Abbreviations*: In an earlier version, you couldn't use abbreviations. `\x y. y x x` had to be written `(\x (\y ((y x) x)))`. We've upgraded the parser though, so now it should be able to understand any lambda term that you can.
-*Constants*: (NOT YET IMPLEMENTED!) The combinators `S`, `K`, `I`, `C`, `B`, `W`, and `T` are pre-defined to their standard values. Also, integers will automatically be converted to Church numerals. (`0` is `\s z. z`, `1` is `\s z. s z`, and so on.)
+*Constants*: The combinators `S`, `K`, `I`, `C`, `B`, `W`, and `T` are pre-defined to their standard values. Also, integers will automatically be converted to Church numerals. (`0` is `\s z. z`, `1` is `\s z. s z`, and so on.)
@@ -38,6 +38,7 @@ let and = \l r. l r false in
)
+do eta-reductions too
@@ -78,12 +79,16 @@ Object.prototype.error = function (message, t) {
var parse = make_parse();
function go(source) {
- var string, tree;
+ var string, tree, expr, eta;
try {
tree = parse(source);
- string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
- // string = JSON.stringify(tree.handler(), ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
-// string = tree.handler().to_string();
+ // string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
+ expr = tree.handler();
+ // string = JSON.stringify(expr, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
+// string = expr.to_string() + "\n\n~~>\n\n";
+ string = '';
+ eta = document.getElementById('ETA').checked;
+ string = "("+eta+")"+string + reduce(expr, eta, false).to_string();
} catch (e) {
string = JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);