libera/#commonlisp - IRC Chatlog
Search
21:25:09
pjb
engblom: I already explained to you that you that plists used only EQL to compare the keys!
21:26:29
pjb
engblom: (let* ((plist '("a" (:A 1 :B 2) "b" (:A 3 :B 4))) (keys (loop for (k) on plist by 'cddr collect k))) (loop for k in keys collect (getf plist k))) #| --> ((:a 1 :b 2) (:a 3 :b 4)) |#
21:29:11
pjb
but note that (let ((k 42)) (eq k k)) may return nil or t depending on the implementatioin!
21:30:04
pjb
so while you can find the actual string used as keys, and find them with get or getf (they use EQ to compare the keys), if the keys are numbers, you can't even be sure to be able to retrieve them!
21:31:06
pjb
engblom: if you want to be able to specify the test function, then use a-lists! assoc and rassoc take a :test argument!
21:51:52
engblom
pjb: I think hash table will be the best solution as then I only once need to specify the test function and the code will be easier to read.
21:53:49
pjb
engblom: but equal or equalp are very coarse. Good for strings, but for other keys (eg. vectors or arrays), you may want a more specific test.
22:05:22
engblom
pjb: As alexandria:plist-has-table does not recurse into the lists deeper in, it is not a problem. All the first level keys will be strings.
0:53:50
pdietz
IMO i's a good idea to look in alexandria or other such utility libraries (I like serapeum) for these sorts of things.
5:25:39
beach
phantomics: What would be the point of breaking backward compatibility for the very minor convenience to a very small number of users of Common Lisp?
8:05:28
hayley
I think I found the one good use for SIMPLE-BASE-STRING: one can scan at about 11 Gcharacters/second with BASE-CHAR, as opposed to "only" 4.7 Gcharacters/second with CHARACTER, because one can stuff more characters in a vector register.