Mercurial > repo
comparison interps/lambda/README @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
995:6883f5911eb7 | 996:859f9b4339e6 |
---|---|
1 Lambda calculus interpreter | |
2 (c) Nikita Ayzikovsky, 2006 | |
3 | |
4 Usage: | |
5 | |
6 run lambda.py, which reads a single-line lambda calculus program from stdin. | |
7 | |
8 Syntax: | |
9 | |
10 A program can optionally contain any number of definitions, followed by | |
11 an expression. | |
12 | |
13 Definitions are of the form | |
14 | |
15 name = expression ; | |
16 | |
17 Expressions are standard lambda calculus expressions, with the symbol lambda | |
18 denoted by \. E.g. | |
19 | |
20 \x,y,z.(x (z y)) | |
21 | |
22 Don't forget to surround with brackets anything that ought to be surrounded | |
23 with brackets (any lambda body where something gets applied to something else) | |
24 "\x,y.x y" is an application of \x,y.x to y; but "\x,y.(x y)" is a single function | |
25 of two variables. | |
26 | |
27 IO: | |
28 | |
29 Input is not implemented. | |
30 For output, an expression of the form "text", when evaluated, prints 'text' | |
31 and evaluates to the identity function. | |
32 #show is a special function that evaluates its argument, and prints out | |
33 the result before returning it. | |
34 #list is a special expression that, when evaluated, prints the list of all | |
35 definitions. | |
36 | |
37 | |
38 DEFINITIONS: | |
39 | |
40 Definitions ('name = exp;') are persistent between program runs. To get | |
41 rid of all definitions, remove the file defs.pickle. |