Equality Predicates, 3.1

Here are mnemonic “formulae” to help remember the relationship between eq, eql, equal, equalp, and = in Common Lisp:

  • eq:

    eq: Exact same object in memory

    Think “Exact” for eq.

  • eql:

    eql: eq + little more (for numbers and characters)

    Think “Little more” for eql.

  • equal:

    equal: eql + structural comparison for lists, strings, etc.

    Think “All” for equal – checks all structural elements.

  • equalp:

    equalp: equal + case-insensitive + number type agnostic

    Think “P for Practical” – it’s practical because it ignores case and number types.

  • =:

    =: Numbers are equal regardless of type (float vs. integer)

    Think “= for Numbers” – only used for numeric comparison.

These mnemonics aim to encapsulate the essence of each function:

  • eq is about memory identity.
  • eql extends eq slightly for direct value comparison in some cases.
  • equal checks for structural equivalence beyond what eql does.
  • equalp adds case insensitivity and type flexibility to equal.
  • = is strictly for numeric equality, ignoring type differences.

— Me@2024-12-14 10:57:53 AM

.

.

2024.12.14 Saturday (c) All rights reserved by ACHK