So, I got no sleep last night due to a client project. Profitable, but exhausting. Not wanting to have a Monday go by without a post, however, I thought I would comment on McCarthy’s original definition of Lisp, which is sited here.
There are few times I have felt the privilege of reading code which is awe-inspiringly brilliant. This is one of those times. It is remarkably simple. Take the “and” function, for example:
(defun and. (x y) (cond (x (cond (y 't) ('t '()))) ('t '())))
Translated:
- Define and
condis basically a switch, it looks for the first “car” which is true. So(cond (x ...)means if x then …- Repeat
condwith y 'tis a catch-all so that thecondwill definitely hit something. It is the “default” in the C-style switch. In both case('t '())means, “if nothing before this is true, return false.
You never get to see a definition of the logic behind “and”, “and” just works, however in this case, it is clearly a beautiful and clear construct built out of the language itself. Truly, this is a thing of beauty.