Comparing Stuff: eq, equal, and More
There’s a lot of beautiful symmetry in Lisp. One part of Lisp that isn’t so beautiful, though, involves the commands for comparing things.
If you want to compare two values in Lisp to find out if they are “the same,” you will find a bewildering assortment of different functions that purport to accomplish this. Of these, equal
, eql
, eq
, =
, string-equal
, and equalp
are the most commonly used. A Lisper must understand the subtleties of these functions intimately in order to know how to compare values correctly.
Before we start dissecting this madness, let me give you Conrad’s Rule of Thumb for Comparing Stuff. Follow ...
Get Land of Lisp now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.