X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=lambda_evaluator.mdwn;h=ffe1c9d589bcf8f0ea53b86cb5692ab4ba86622e;hp=4cf073616c23eca99b37672019949d79b5b93dfc;hb=f5940a5f1336b330235676932fcb70e038e75c8d;hpb=08e5cbb580b637a3e4c92fbb4fbb9f7891b81103 diff --git a/lambda_evaluator.mdwn b/lambda_evaluator.mdwn index 4cf07361..ffe1c9d5 100644 --- a/lambda_evaluator.mdwn +++ b/lambda_evaluator.mdwn @@ -6,14 +6,32 @@ It will allow you to write lambda terms and evaluate them, with full ability to (This won't work in Racket, because Racket doesn't even try to represent the internal structure of a function in a human-readable way.) *Lambda terms*: lambda terms are written with a backslash, thus: `((\x (\y x)) z)`. -If you click "Reduce", the system will produce a lambda term that is guaranteed to be reduction equivalent (`<~~>`) with the original term. +If you click "Reduce", the system will produce a lambda term that is guaranteed to be reduction equivalent (`<~~>`) with the original term. So `((\x (\y x)) z)` reduces to (a lambda term equivalent to) `(\y z)`. -*Let*: in order to make building a more elaborate system easier, it is possible to define values using `let`. +*Let*: in order to make building a more elaborate set of terms easier, it is possible to define values using `let`. In this toy system, `let`s should only be used at the beginning of a file. If we have, for intance, let true = (\x (\y x)) in let false = (\x (\y y)) in + ((true yes) no) + +the result is `yes`. Things to watch out for: the expression after the equal sign must have balanced parentheses, +and the "in" is obligatory. If you violate these rules, the system will still produce a result, but it won't make much sense. + +*Abbreviations*: No abbreviations work. So `\xy.yxx` must be written `(\x (\y ((y x) x)))`. (As in Scheme or Racket.) + +*Comments*: anything following a semicolon to the end of the line is ignored. +Blank lines are fine. + +Under the hood +--------------- + +The interpreter is written in JavaScript (which is not closely related to Java), and runs inside your browser. +So if you decide to reduce a term that does not terminate (such as `((\x (x x)) (\x (x x)))`), it will be your +browser that stops responding, not the wiki server. + +You can inspect the code [here](http://lambda.jimpryor.net/code/lambda.js). Suggestions for improvements welcome. + +Improvements we hope to add soon: the ability to reduce Combinatory Logic combinators; the ability to translate from CL to the lambda calculus; and more sensible variable names instead of `g354`. -*Comments*: -[more soon]