equalp
equalp x y → generalized-boolean
x—an object.
y—an object.
generalized-boolean—a generalized boolean.
6.3.0 21
6.3.0 22Returns true if x and y are equal, or if they have components that are of the same type as each other and if those components are equalp; specifically, equalp returns true in the following cases:
If two characters are char-equal.
If two numbers are the same under =. Change made due to v8 of EQUAL-STRUCTURE. -kmp 30-Jan-92
have the same numerical value (even if they are of different
\term{types}),
or if they have components that are all \funref{equalp}.
If the two cars in the conses are equalp and the two cdrs in the conses are equalp. Laubsch thinks this goes without saying (and I agree.) -kmp 19-Jan-92
(defined recursively).
6.3.0 23If two arrays have the same number of dimensions, the dimensions match, and the corresponding "components" => "active elements" -kmp 30-Jan-92active elements are equalp. The types for which the arrays are specialized need not match; for example, a string and a general array that happens to contain the same characters are equalp. Not needed with "components" => "active elements" above. -kmp 30-Jan-92
If either \param{x} or \param{y} has a \term{fill pointer},
the \term{fill pointer} limits the number of elements examined by \funref{equalp}.Because equalp performs element-by-element comparisons of strings and ignores the case of characters, case distinctions are ignored when equalp compares strings.
Barmar points out these are implied by the remarks about EQUAL in the first paragraph. \itemitem{\term{Symbols}} 6.3.0 24 If two \term{symbols} are \term{identical}. \issue{EQUAL-STRUCTURE:MAYBE-STATUS-QUO} \itemitem{\term {Structures}, \term{Instances}, other} If two \term{structures}, \term{hash tables}, \term{instances}, or other \term{objects} are \term{identical}. \endissue{EQUAL-STRUCTURE:MAYBE-STATUS-QUO}
Here's the text of the cleanup issue.
EQUALP on two DEFSTRUCT objects 's1' and 's2', where one is a
non-:TYPEed DEFSTRUCT and the other is typed, is false.
EQUALP on two DEFSTRUCT objects 's1' and 's2', where both are
non-:TYPEed DEFSTRUCTS is true iff:
(1) The type of 's1' is the same as the type of 's2' (this is
the same as saying that the defstruct name for 's1' is the same
as that for 's2').
(2) The value of each slot of 's1' is EQUALP to the value of the
same slot of 's2' (where "same" means same name) (this is not the
This doesn't use the same wording as in the cleanup, but I couldn't figure
out that wording. -kmp 30-Jan-92If two structures and have the same class and the value of each slot in is the same under equalp as the value of the corresponding slot in .
If two \term{hash tables} are \funref{equalp}.equalp descends hash tables by first comparing the count of entries and the :test function; if those are the same, it compares the keys of the tables using the :test function and then the values of the matching keys using equalp recursively.
equalp does not descend any objects other than the ones explicitly specified above. The next figure summarizes the information given in the previous list. In addition, the figure specifies the priority of the behavior of equalp, with upper entries taking priority over lower ones.
| Type | Behavior |
| number | uses = |
| character | uses char-equal |
| cons | descends |
| bit vector | descends |
| string | descends |
| pathname | same as equal |
| structure | descends, as described above |
| Other array | descends |
| hash table | descends, as described above |
| Other object | uses eq |
Figure 5–13. Summary and priorities of behavior of equalp
6.3.0 25
(equalp 'a 'b) → false (equalp 'a 'a) → true (equalp 3 3) → true (equalp 3 3.0) → true (equalp 3.0 3.0) → true (equalp #c(3 -4) #c(3 -4)) → true (equalp #c(3 -4.0) #c(3 -4)) → true (equalp (cons 'a 'b) (cons 'a 'c)) → false (equalp (cons 'a 'b) (cons 'a 'b)) → true (equalp #\A #\A) → true (equalp #\A #\a) → true (equalp "Foo" "Foo") → true (equalp "Foo" (copy-seq "Foo")) → true (equalp "FOO" "foo") → true
(setq array1 (make-array 6 :element-type 'integer
:initial-contents '(1 1 1 3 5 7)))
→ #(1 1 1 3 5 7)
(setq array2 (make-array 8 :element-type 'integer
:initial-contents '(1 1 1 3 5 7 2 6)
:fill-pointer 6))
→ #(1 1 1 3 5 7)
(equalp array1 array2) → true
(setq vector1 (vector 1 1 1 3 5 7)) → #(1 1 1 3 5 7)
(equalp array1 vector1) → true
None.
None.
None.
eq, eql, equal, =, string=, string-equal, char=, char-equal
Object equality is not a concept for which there is a uniquely determined correct algorithm. The appropriateness of an equality predicate can be judged only in the context of the needs of some particular program. Although these functions take any type of argument and their names sound very generic, equal and equalp are not appropriate for every application.