@riley @dougmerritt
Yeah,
(let ((alist '((:foo . bar) (:baz buz))))
(cdr (assoc :foo alist)) ; -> bar
(cadr (assoc :baz alist))) ; -> buz
There isn't a lot of cost (well, one cons to nil) of using cadr or second instead of cdr. And then you could store other stuff in later positions of the list as well. When I only knew the definitions of assoc and pairlis, I mostly used cdr, but then in lisp code I've read, like you said, the cadr one seems more common in lots of places.
Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Monday, 17-Feb-2025 17:41:28 JST screwlisp