Function: equal

equal is a function defined in fns.c.

Signature

(equal O1 O2)

Documentation

Return t if two Lisp objects have similar structure and contents.

They must have the same data type. Conses are compared by comparing the cars and the cdrs. Vectors and strings are compared element by element. Numbers are compared via eql, so integers do not equal floats.
(Use = if you want integers and floats to be able to be equal.)
Symbols must match exactly.

Other relevant functions are documented in the comparison, symbol and string groups.

View in manual

Probably introduced at or before Emacs version 19.29.

Shortdoc

;; string
(equal "foo" "foo")
    => t
;; symbol
(equal 'abc 'abc)
    => t
;; comparison
(equal "abc" "abc")
    => t
  (equal 2.0 2.0)
    => t
  (equal 2.0 2)
    => nil
  (equal '(a "b" (c) 4.0) '(a "b" (c) 4.0))
    => t

Source Code

// Defined in /usr/src/emacs/src/fns.c
{
  return internal_equal (o1, o2, EQUAL_PLAIN, 0, Qnil) ? Qt : Qnil;
}