From: Jeff Cunningham
Subject: How can I compose a symbol from a string?
Date: 
Message-ID: <pan.2005.09.03.23.30.25.140664@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

From: Wade Humeniuk
Subject: Re: How can I compose a symbol from a string?
Date: 
Message-ID: <9XqSe.253789$on1.80401@clgrps13>
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
From: Wade Humeniuk
Subject: Re: How can I compose a symbol from a string?
Date: 
Message-ID: <S1rSe.253793$on1.223539@clgrps13>
and...

(defun joinsyms (plist key1 key2 val)
   (setf (getf plist (concat-keywords key1 key2)) val)
   plist)

CL-USER 1 > (joinsyms (list :sym1 "val1" :sym2 "val2") :sym1 :sym2 "val3")
(:SYM1-SYM2 "val3" :SYM1 "val1" :SYM2 "val2")

CL-USER 2 >

Wade
From: Jeff Cunningham
Subject: Re: How can I compose a symbol from a string?
Date: 
Message-ID: <pan.2005.09.04.03.46.36.514624@cunningham.net>
On Sun, 04 Sep 2005 00:16:50 +0000, Wade Humeniuk wrote:

> 
> and...
> 
> (defun joinsyms (plist key1 key2 val)
>    (setf (getf plist (concat-keywords key1 key2)) val)
>    plist)
> 
> CL-USER 1 > (joinsyms (list :sym1 "val1" :sym2 "val2") :sym1 :sym2 "val3")
> (:SYM1-SYM2 "val3" :SYM1 "val1" :SYM2 "val2")
> 
> CL-USER 2 >
> 
> Wade

Oooo - I like it! Thank you. I learned at least one new trick.

--Jeff
From: Andreas Thiele
Subject: Re: How can I compose a symbol from a string?
Date: 
Message-ID: <dfde50$m2r$01$1@news.t-online.com>
"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