Use assoc with argument of type string
Posted: Sun Jun 17, 2012 5:00 am
Hi everybody,
I have this association-list:
I have to call assoc when my argument is of type string.
So for the pair I have to convert "a" to a symbol, and for the pair I have to convert "2" to a symbol. How can I do that?
This should work like this:
I tried using intern but got NIL:
Thanks a lot
I have this association-list:
Code: Select all
(defvar base-list (list (cons 'a 0) (cons 2 'c)))
So for the pair
Code: Select all
(A . 0)
Code: Select all
(2 . C)
This should work like this:
Code: Select all
CL-USER 28 : 1 > (assoc (convert-string-to-symbol "a") base-list)
(A . 0)
CL-USER 28 : 1 > (assoc (convert-number-to-symbol "2") base-list)
(2 . C)
Code: Select all
CL-USER 29 : 1 > (assoc (intern "a") base-list)
NIL