You can use lists as alist keys too. E.g.,
(assoc '(1 2) '(((1 1) a) ((1 2) b) ((1 3) c)) :test #'equal)
==> ((1 2) B)
So, if you have a list of people
(defparameter *people* '((Ben Hofferber) (Adam Young)))
you can set their ages like this:
(defparameter *ages* (mapcar #'list *people* '(20 11)))
and find them like this:
(assoc '(Ben Hofferber) *ages* :test #'equal)
==> ((BEN HOFFERBER) 20)
If, however, you insist on combining symbols into one, you will have to explain how you want to do that.
If both symbols are in the same package, the combined symbols can be placed there too:
(defun combine-symbols (s1 s2)
(intern (concatenate 'string (symbol-name s1) "-" (symbol-name s2))
(symbol-package s1)))
but if they are in different packages (e.g., cl:car
and cl-user::ben
), you would have to make a tough choice which package to go with.
Alternatively, you can go with strings and use
(defun combine-objects (o1 o2)
(format nil "~A-~A" o1 o2))
Don't forget to pass :test #'equal
or :test #'string=
to assoc
.