This is my old blog. My new ones are herdrick.tumblr.com or herdrick.posterous.com

Monday, February 19, 2007

atom? - Get it right.

Since Google seems to be having a hard time finding it the right definition, I'd like to point out for the record that in Scheme, atom? should be defined so:


(define atom?
(lambda (x)
(and (not (pair? x)) (not (null? x)))))

Other definitions should be stoned to death or at least given a very dirty look.

Thank you for your attention to this matter.

Thursday, February 08, 2007

Fever's break

Upon emerging from the worst of my head-cold chest-cold fever, I realized: association lists work fine for any arbitrary key/value pairs. A very obvious thing I suppose, but something had been throwing me off when I was thinking of alists this morning. When you cons the key onto the value, but the value is a list, then the resulting alist entry isn't a dotted pair, it's just a plain old list. But who cares? Functionally it's identical. It may as well be a dotted pair. Look:

(a . (1 2 3))
(a 1 2 3))

Are the car and cdr of this any different? No.

Obvious, yes, but I had a fever! I was lucky to be thinking at all. Get off my case!