ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL
Home Previous Up Next Table of Contents Index
  ANSI Common Lisp   5 Data and Control Flow   5.3 Dictionary of Data and Control Flow

5.3.35 equal Function

Syntax:
equal x y    generalized-boolean

Arguments and Values:
x - an object.

y - an object.

generalized-boolean - a generalized boolean.

Description:
Returns true if x and y are structurally similar (isomorphic) objects. Objects are treated as follows by equal.

equal 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 equal, with upper entries taking priority over lower ones.

Summary and priorities of behavior of
Type Behavior
number uses eql
character uses eql
cons descends
bit vector descends
string descends
pathname "functionally equivalent"
structure uses eq
Other array uses eq
hash table uses eq
Other object uses eq

Any two objects that are eql are also equal.

equal may fail to terminate if x or y is circular.

Examples:
 (equal 'a 'b)  false
 (equal 'a 'a)  true
 (equal 3 3)  true
 (equal 3 3.0)  false
 (equal 3.0 3.0)  true
 (equal #c(3 -4) #c(3 -4))  true
 (equal #c(3 -4.0) #c(3 -4))  false
 (equal (cons 'a 'b) (cons 'a 'c))  false
 (equal (cons 'a 'b) (cons 'a 'b))  true
 (equal #\A #\A)  true
 (equal #\A #\a)  false
 (equal "Foo" "Foo")  true
 (equal "Foo" (copy-seq "Foo"))  true
 (equal "FOO" "foo")  false
 (equal "This-string" "This-string")  true
 (equal "This-string" "this-string")  false

See Also:
eq, eql, equalp, =, string=, string-equal, char=, char-equal, tree-equal

Notes:
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.

A rough rule of thumb is that two objects are equal if and only if their printed representations are the same.

Allegro CL Implementation Details:
None.

Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2015 - File last updated 03-23-2015