t when arg1 and arg2 are the same object. Two
objects are the same object when they occupy the same place in memory and
hence modifying one object would alter the other. The following Lisp
fragments may illustrate this,
(eq "foo" "foo") ;the objects are distinct
=> nil
(eq t t) ;the same object -- the symbol t
=> t
Note that the result of eq is undefined when called on two integer
objects with the same value, see eql.
equal compares the structure of the two objects arg1
and arg2. If they are considered to be equivalent then t is
returned, otherwise nil is returned.
(equal "foo" "foo")
=> t
(equal 42 42)
=> t
(equal 42 0)
=> nil
(equal '(x . y) '(x . y))
=> t
eq and equal: if arg1
and arg2 are both numbers then the value of these numbers are compared.
Otherwise it behaves in exactly the same manner as eq does.
(eql 3 3)
=> t
(eql 1 2)
=> nil
(eql "foo" "foo")
=> nil
(eql 'x 'x)
=> t
Go to the first, previous, next, last section, table of contents.