331 lines
72 KiB
Plaintext
331 lines
72 KiB
Plaintext
Copyright (c) 1986 Xerox Corporation. All rights reserved.
|
||
|
||
2
|
||
|
||
3.11 Other List Functions
|
||
1
|
||
|
||
(REMOVE X L) [Function]
|
||
1
|
||
|
||
Removes all top-level occurrences of X from list L, returning a copy of L with all elements EQUAL to X removed. Example:
|
||
(REMOVE 'A '(A B C (A) A)) => (B C (A))
|
||
(REMOVE '(A) '(A B C (A) A)) => (A B C A)
|
||
1
|
||
|
||
(DREMOVE X L) [Function]
|
||
1
|
||
|
||
Similar to REMOVE, but uses EQ instead of EQUAL, and actually modifies the list L when removing X, and thus does not use any additional storage. More efficient than REMOVE.
|
||
Note that DREMOVE cannot change a list to NIL:
|
||
_(SETQ FOO '(A))
|
||
(A)
|
||
_(DREMOVE 'A FOO)
|
||
NIL
|
||
_FOO
|
||
(A)
|
||
The DREMOVE above returns NIL, and does not perform any CONSes, but the value of FOO is still (A), because there is no way to change a list to a non-list. See NCONC.
|
||
1
|
||
|
||
(REVERSE L) [Function]
|
||
1
|
||
|
||
Reverses (and copies) the top level of a list, e.g.,
|
||
(REVERSE '(A B (C D))) => ((C D) B A)
|
||
If L is not a list, REVERSE just returns L.
|
||
1
|
||
|
||
(DREVERSE L) [Function]
|
||
1
|
||
|
||
Value is the same as that of REVERSE, but DREVERSE destroys the original list L and thus does not use any additional storage. More efficient than REVERSE.
|
||
1
|
||
|
||
(COMPARELISTS X Y) [Function]
|
||
1
|
||
|
||
Compares the list structures X and Y and prints a description of any differences to the terminal. If X and Y are EQUAL lists, COMPARELISTS simply prints out SAME. Returns NIL.
|
||
COMPARELISTS prints a terse description of the differences between the two list structures, highlighting the items that have changed. This printout is not a complete and perfect comparison. If X and Y are radically different list structures, the printout will not be very useful. COMPARELISTS is meant to be used as a tool to help users isolate differences between similar structures.
|
||
When a single element has been changed for another, COMPARELISTS prints out items such as (A -> B), for example:
|
||
_(COMPARELISTS '(A B C D) '(X B E D))
|
||
(A -> X) (C -> E)
|
||
NIL
|
||
When there are more complex differences between the two lists, COMPARELISTS prints X and Y, highlighting differences and abbreviating similar elements as much as possible. "&" is used to signal a single element that is present in the same place in the two lists; "--" signals an arbitrary number of elements in one list but not in the other; "-2-," "-3-," etc signal a sequence of two, three, etc. elements that are the same in both lists. Examples:
|
||
(COMPARELISTS '(A B C D) '(A D))
|
||
(A B C --)
|
||
(A D)
|
||
_(COMPARELISTS '(A B C D E F G H) '(A B C D X))
|
||
(A -3- E F --)
|
||
(A -3- X)
|
||
_(COMPARELISTS '(A B C (D E F (G) H) I) '(A B (G) C (D E F H) I))
|
||
(A & & (D -2- (G) &) &)
|
||
(A & (G) & (D -2- &) &)
|
||
1
|
||
|
||
(NEGATE X) [Function]
|
||
1
|
||
|
||
For a form X, returns a form which computes the negation of X . For example:
|
||
(NEGATE '(MEMBER X Y)) => (NOT (MEMBER X Y))
|
||
(NEGATE '(EQ X Y)) => (NEQ X Y)
|
||
(NEGATE '(AND X (NLISTP X))) => (OR (NULL X) (LISTP X))
|
||
(NEGATE NIL) => T
|
||
1
|
||
|
||
|