|
|
|
|
|
by anthk
79 days ago
|
|
More like 1 = 0 + 1. Read about Lisp, the Computational Beauty of Nature, 64k Lisp from https://t3x.org and how all numbers can be composed of counting nested lists all down. List of a single item: (cons '1 nil)
Nil it's an empty atom, thus, this reads as:[ 1 | nil ] List of three items: (cons '1 (cons 2 (cons 3 nil)))
Which is the same as (list '1 '2 '3)
Internally, it's composed as is,
imagine these are domino pieces chained.
The right part of the first one points
to the second one and so on.[ 1 | --> [ 2 | -> [ 3 | nil ] A function is a list, it applies the operation
over the rest of the items: (plus '1 '2 3')
Returns '6Which is like saying: (eval '(+ '1 '2 '3))
'(+ '1 '2 '3) it's just a list, not a function,
with 4 items.Eval will just apply the '+' operation
to the rest of the list, recursively. Whis is the the default for every list
written in parentheses without the
leading ' . (+ 1 (+ 2 3))
Will evaluate to 6, while (+ '1 '(+ '2 '3))
will give you an error
as you are adding a number and a list
and they are distinct items
themselves.How arithmetic is made from 'nothing': https://t3x.org/lisp64k/numbers.html Table of contents: https://t3x.org/lisp64k/toc.html Logic, too: https://t3x.org/lisp64k/logic.html |
|