name(s) | type | args | examples |
---|---|---|---|
nil true false | constants | ||
cons | function | 2 | cons 4 '(2) |
car cdr | functions | 1 | car '(4 2) cdr '(4 2) |
cadr caddr | functions | 1 | cadr '(1 2 3 4) caddr '(1 2 3 4) |
append | function | 2 | append '(1 2 3) '(3 4 5) |
length | function | 1 | length '(2 2 2) |
atom | function | 1 | atom 42 |
+ - * ^ | functions | 2 | * 6 7 ^ 2 10 |
= | function | 2 | = '(1 2) '(2 1) |
< > <= >= | functions | 2 | < 1 2 >= 42 43 |
base10-to-2 | function | 1 | base10-to-2 42 |
base2-to-10 | function | 1 | base2-to-10 '(1 0 1 0 1 0) |
if | macro | 3 | if atom nil 42 43 |
' | macro | 1 | '(1 2 3 4) |
" | macro | 1 | "(car (' (1 2))) |
lambda | function | 2 | ('lambda (x) + 40 x 2) |
let | macro | 3 | let (f x y) (* x y) (f 6 7) let x 2 (+ 40 x) |
eval | function | 1 | eval '(* 3 14) |
size | function | 1 | size '(cons 2 nil) |
success failure | constants | ||
no-time-limit out-of-time out-of-data | constants | ||
display debug | function | 1 | display - 50 8 |
try | macro | 3 | try no-time-limit 'display read-bit '(1 0) |
bits | function | 1 | bits '(cons 1 nil) |
read-bit read-exp | functions | 0 | try 100 'read-exp bits '+ 3 4 |
run-utm-on | macro | 1 | run-utm-on bits ' * 6 7 |
The interpreter should behave exactly like Chaitin's original Lisp as the WASM file was created from his C code; I just added the run-utm-on macro from the book. You can type Lisp code into the text area and use the Send button to send it to the interpreter. (Alternatively, you can press Shift-Return.) The output will be shown in the gray region below the textarea. You can also drag and drop text files with Lisp code (like these) onto the text area. Note that you'll have to use Chaitin's "M-expression" syntax which feels slightly weird for experienced Lisp hackers: car '(a b) is OK while (car '(a b)) won't work as expected. You can, however, use the double-quote escape mechanism and type the somewhat clumsy "(car (' (a b))). To see a "cheat sheet" press F1 or click here.
Input from the text area is "cleaned" before it is sent to Lisp - which means that all but a few strictly necessary ASCII characters (letters, digits, and about half a dozen other symbols like parentheses) are removed. It's OK to enter several expressions at once, but incomplete M-expressions like cons '(a b) will be ignored.
Everything happens in the same image (or "session"), i.e. the Lisp "remembers" the side effects of your previous inputs. If you want to restart the Lisp image, you have to reload the page.
Note that this is a very minimalistic Lisp which was created to prove mathematical theorems. It is not meant to be a general-purpose programming language like Common Lisp.