3 ms·
How would that work? I've only come across recursive function application as a way to implement Peano/Church numerals, similar to how it might be done in Prolog
by cess11 3y ago
How would that work? I've only come across recursive function application as a way to implement Peano/Church numerals, similar to how it might be done in Prolog:
natnum(0).
natnum(s(N)) :-
natnum(N).
- Drakim 3y agoI have no idea if this is actually the case with early Lisp, but when I was making my own vaguely Lisp-alike interpreter, it became awfully tempting to make everything into a list. After all, arrays are lists, strings are lists of characters, and even structs can be thought of as a list with unorthodox indexing. At one point I was faced with the fact that I only really had 2 datatypes in my interpreter, the list and the integer. So I bit the bullet and made my integer type into a list with one byte entry, thus reducing my total amount of datatypes to one. Every piece of my interpreter code always knew that it would get a list as inputs, and it was kinda beautiful. CPU-wise it was wasteful, but it reduced the interpreter size by a lot.
- EdwardCoffin 3y agoI believe the microprocessor from Steele's and Sussman's paper Design of a LISP-based microprocessor [1] used Peano numbers. [1] https://dl.acm.org/doi/pdf/10.1145/359024.359031 https://dl.acm.org/doi/pdf/10.1145/359024.359031
- cess11 3y agoUnder 10. Discussion they discuss the lack of numbers and how they're using CONS as a kind of 'add 1' and CAR/CDR as a kind of 'subtract 1' when calculating positions in memory, similar to how integer index/pointers might be used on a different type of machine, as if the length of a list would be an implicit pointer. They seem almost giddy about having designed a computer that can perform interesting mathematical tasks like integrals and derivatives without numbers.