3 ms·
I did a length:data encoding in the fake Lisp-like library in cppawk. Haha. For instance cons(1, 1) produces "C1,1:12". Type code C followed by two decimal in
by kazinator 3y ago
I did a length:data encoding in the fake Lisp-like library in cppawk. Haha.
For instance cons(1, 1) produces "C1,1:12". Type code C followed by two decimal integers separated by a comma, terminated by colon, followed by the car/cdr data. The decimal integers give the lengths of the car and cdr part after the colon.
https://www.kylheku.com/cgit/cppawk/tree/cppawk-cons.1 https://www.kylheku.com/cgit/cppawk/tree/cppawk-cons.1
The list (1 2 3) looks like "C1,12:1C1,6:2C1,0:3" .
A cursory scan through the string tells us that there are three C's, so three cells in there.
Note the C1,0:3 at the end: (3 . nil). nil is a zero length object: the empty string represents nil. So the cdr length of the last cell is zero.