Just out of curiosity, if I wanted to be able to build a symbol out of
two other symbols:
(let ((plist (:sym1 "val1" :sym2 "val2")))
(print (joinsyms plist :sym1 :sym2 "val3")))
so that joinsyms would produce a plist like this:
> (:sym1 "val1" :sym2 "val2" :sym1-sym2 "val3")
What would joinsyms look like? Is it even possible?
I tried playing around with make-symbol but I always get stuff that
looks like (#:|sym1-sym2| "val3").
-jeff cunningham
Jeff Cunningham wrote:
> Just out of curiosity, if I wanted to be able to build a symbol out of
> two other symbols:
>
> (let ((plist (:sym1 "val1" :sym2 "val2")))
> (print (joinsyms plist :sym1 :sym2 "val3")))
>
> so that joinsyms would produce a plist like this:
>
>
>>(:sym1 "val1" :sym2 "val2" :sym1-sym2 "val3")
>
>
> What would joinsyms look like? Is it even possible?
>
> I tried playing around with make-symbol but I always get stuff that
> looks like (#:|sym1-sym2| "val3").
>
Try this,
(defun concat-keywords (keyword1 keyword2)
(assert (and (keywordp keyword1) (keywordp keyword2)))
(intern (format nil "~A-~A" keyword1 keyword2) :keyword))
CL-USER 1 > (concat-keywords :sym1 :sym2)
:SYM1-SYM2
NIL
CL-USER 2 >
Wade
"Jeff Cunningham" <·······@cunningham.net> schrieb im Newsbeitrag
···································@cunningham.net...
> Just out of curiosity, if I wanted to be able to build a symbol out of
> two other symbols:
>
> (let ((plist (:sym1 "val1" :sym2 "val2")))
> (print (joinsyms plist :sym1 :sym2 "val3")))
>
> so that joinsyms would produce a plist like this:
>
> > (:sym1 "val1" :sym2 "val2" :sym1-sym2 "val3")
>
> What would joinsyms look like? Is it even possible?
>
> I tried playing around with make-symbol but I always get stuff that
> looks like (#:|sym1-sym2| "val3").
>
>
> -jeff cunningham
>
>
I think read-from-string and format can be your friends:
CL-USER 3 > (read-from-string "sym1")
SYM1
4
CL-USER 4 > (read-from-string ":sym1")
:SYM1
5
CL-USER 5 > (format nil "~a" :sym1)
"SYM1"
CL-USER 6 > (format nil "~a" 'sym1)
"SYM1"
Andreas