ch1_4_conscells
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ch1_4_conscells [2024/05/04 09:55] – admin | ch1_4_conscells [2024/05/05 11:23] (current) – admin | ||
---|---|---|---|
Line 3: | Line 3: | ||
//There is no list// | //There is no list// | ||
- | We have learned that Lisp expressions consist of atoms and lists, but in fact, there is no //list// object in the background. A list in Lisp is constructed with objects called // | + | We have learned that Lisp expressions consist of atoms and lists, but in fact, there is no //list// object in the background. A list in Lisp is constructed with objects called // |
Conscell is an object holding two pointers, the first points to an element of the list and the second points to the next conscell. That means Lisp lists are // | Conscell is an object holding two pointers, the first points to an element of the list and the second points to the next conscell. That means Lisp lists are // | ||
- | For historical reasons, the pointers are called | + | For historical reasons, the pointers are called |
{{ : | {{ : | ||
- | For example, list with a sublist | + | For example, list with a sublist '' |
{{ : | {{ : | ||
+ | |||
+ | Proper list ends with a conscell, which has '' | ||
+ | |||
+ | Lisp allows us to construct list directly using '' | ||
+ | |||
+ | <code lisp> | ||
+ | >(cons 'a (cons 'b (cons 'c nil))) | ||
+ | (A B C) | ||
+ | </ | ||
+ | |||
+ | The code above produces exactly the same list as when using '' | ||
+ | |||
+ | <code lisp> | ||
+ | >(list 'a 'b 'c) | ||
+ | (A B C) | ||
+ | |||
+ | >' | ||
+ | (A B C) | ||
+ | </ | ||
+ | |||
+ | The power and simplicity of Lisp originates from the fact that code is a list of lists and atoms, exactly the same structure connected with conscells, as is any user-defined data list. Lisp macros can manipulate the code using any of the functions that manipulate data lists. | ||
+ | |||
+ | FIXME | ||
+ | |||
+ | Show more examples, cons, car, cdr, link to List Processing Functions. | ||
+ | Show functionality of accessors and SETF shenanigans. Link to Cycles. | ||
+ | Dotting. | ||
+ | Show list with nil element, or (nil) sublist. | ||
+ | |||
+ |
ch1_4_conscells.1714838132.txt.gz · Last modified: 2024/05/04 09:55 by admin