T
T
thewizardplusplus2014-01-16 18:38:40
Lisp
thewizardplusplus, 2014-01-16 18:38:40

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

6 answer(s)
K
Konstantin Kitmanov, 2014-01-17
@thewizardplusplus

What is the "minimal" set of primitives needed for...
The Lisp defined in McCarthy's 1960 paper, transla...

Y
Yoschi, 2014-01-16
@Yoschi

(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.

W
webbus, 2014-01-16
@webus

Look at the Clojure implementation

I
ilammy, 2014-03-07
@ilammy

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.

V
Vasily minodvesP, 2014-08-22
@benoni

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)

M
MDtox, 2018-04-19
@MDtox

Don't forget to remove the brackets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question