4 ms·
You'll need car, cdr, cons, atom, and eq. You'll also need ratom and patom for input and output. That's 7 primitive functions. To be able to define recursi
by DonaldFisk 5y ago
You'll need car, cdr, cons, atom, and eq. You'll also need ratom and patom for input and output. That's 7 primitive functions.
To be able to define recursive functions, you'll also need cond, lambda, setq (or define), quote, and function. That's five special forms.
Then you have to write read, eval, apply, and print in your implementation language. That gives you a minimal interpreter. These four functions aren't primitives, but you have to write them and you might as well expose them to the user. Eval and apply call a few other functions which are generally useful, such as assoc, evlis and pairlis.
This excludes arithmetic functions and a whole lot of other stuff you'd need for your interpreter to be useful.
- brundolf 5y agoTechnically I think you could implement arithmetic as recursive functions operating on lists of different lengths.....
- mpfundstein 5y agoyou just inspired me to re-read GEB part 1 :-)
- DonaldFisk 5y agoInterestingly, this was more or less the way that Lenat's program AM discovered numbers, and later arithmetic.
- brundolf 5y agoHah, I actually used to work for Lenat but I didn't know this :)