Answer the question
In order to leave comments, you need to log in
How to simplify LISP?
For academic purposes, I want to use the task of writing a LISP interpreter. A fairly common practice. However, LISP is still too complicated for my purposes, so I want to simplify it. And since I am not a professional of this language, I decided to consult if I would throw out something necessary.
So, I want to do the following:
1) from atoms, leave only integer decimal numbers and identifiers (consisting of letters and an underscore);
2) remove dotted pairs altogether (they can be replaced by lists of two elements);
3) leave only these functions: cons, car, cdr, if, defun, quote and even arithmetic ones.
Will this language remain Turing complete? Did I throw out something necessary? Or vice versa, maybe left something redundant?
My goal is to keep the spirit of LISP while keeping the syntax as short as possible.
Answer the question
In order to leave comments, you need to log in
What is the "minimal" set of primitives needed for...
The Lisp defined in McCarthy's 1960 paper, transla...
(cons 1 2) => '(1 . 2)
And a two-element list is (cons 1 (cons 2 nil))
So I'm afraid you can't do without dotted pairs. They are not related specifically to "pairs of elements", but to the construction of list cells. Try (cons 1 (cons 2 3)) and see.
By the way, you will also need the mentioned nil (and, accordingly, T).
Comparison is required. I do not exclude that you added it to the arithmetic functions, but the comparison of logical values is also an absolutely necessary thing.
And finally, you need the ability to distinguish a list from an atom. As far as I remember, atomp or consp is necessarily included in the Lisp core. This does not seem to affect Turing completeness, but it will not work to implement it outside the kernel, as a function using primitives.
According to Turing, Lisp will remain complete even if one lambda is left in it.
And Lisp itself is a very simple language. If you don't want to implement all sorts of floating points and strings on your own, write an interpreter in Lisp itself.
mr.gy/software/microlisp
Zs I myself am still a complete teapot in l / hypo-like languages, so I don’t know how much this dialect that I gave the link fits the task) but since it’s micro, it means that the most necessary current is left there - in theory)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question