分类: LINUX
2011-05-02 23:34:42
In Lisp, there is a set of functions which work for different kind of object:
EQ EQL EQUAL EQUALP
The function with the shorter name support stricter definition of equality. The functions with the longer implement less restrictive, perhaps more intuitive, definitions of equality.
EQ is true for identical symbols. In fact, it’s true for any identical object. You can consider that EQ compare the memory address of objects. For example, you have a list, this list is EQ to itself, but it not EQ to another list with identical items. You also can use EQ to compare number and character, but this is not a good idea to do it.
EQL keeps EQ’s feature, and extends it to identical numbers and character. But EQL requires the identical type, thus 0.0 is not EQL to 0. EQL is case sensitive.
EQUAL is true for things that print the same. EQ and EQL are not true for lists have the same structure and items. EQUAL is true for those list.
EQUALP ignores number type and character case. EQUALP is the most permissive of the core comparison functions.Everything that is EQUAL is also EQUALP. But EQUALP ignores case distinctions between characters, and applies the (typeless) mathematical concept of equality to numbers; thus 0.0 is EQUALP to 0