Can someone tell me how to concatenate a list of symbols into a new
symbol in
common lisp?
I'd like to take a list such as (ab cd ef gh) and generate the
keyword :abcdefg,
not knowing in advance whether such a keyword already exists.
any suggestions?
-jim
Here is my attempt. Is there an better way?
(defun concat (list)
(intern (apply 'concatenate 'string (mapcar 'symbol-name list))
(find-package :keyword)))
By the way, i have no idea why the new google groups client
which i use to post to comp.lang.list thinks my name is
"cadence".
-jim
On Feb 4, 1:07 pm, "cadence" <····@rdrop.com> wrote:
> Can someone tell me how to concatenate a list of symbols into a new
> symbol in
> common lisp?
> I'd like to take a list such as (ab cd ef gh) and generate the
> keyword :abcdefg,
> not knowing in advance whether such a keyword already exists.
>
> any suggestions?
> -jim
+ "cadence" <·····@rdrop.com>:
| Here is my attempt. Is there an better way?
|
| (defun concat (list)
| (intern (apply 'concatenate 'string (mapcar 'symbol-name list))
| (find-package :keyword)))
No need for find-package. :keyword on its own is a valid package
designator (see also Pascal Costanza's solution).
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
So I get an automated call from the CC security folks saying I had one
day to confirm a purchase via their automated system, which asks me to
key in the first three letters of my mother's maiden name or, if I have
a password instead, of that password. I do have a password so I key in
the first three letters YOB, failing three times. So I just make a
regular call to the CC number and ask them if they have the password
YOBBO spelled correctly -- hey, even I thought it was YABBO at first,
not knowing the derivation ("boy" backwards).
The helpful operator says, no, we have YOBBO. To use an automated system
you should key in 7-9-9, not 9-6-2. I look at my phone for a second and
say, Sorry? He then confesses: when you change to password from mother's
maiden name, they enter the only field they have (m-m-n) as
"PW"+password, or PWYOBBO, so they know it is a password. I burst out
laughing and explain I am a computer geek so I love that stuff.
The operator helpfully suggests that I could avoid this problem by
simply saying that my mother's maiden name is YOBBO, no one will make
fun of me. He also takes care of confirming the purchase over the phone,
while I try to figure out how to sell "Hi, I need to change my mother's
maiden name..." to the next operator.
This almost made me forget about the insurance company that required a
visual inspection of a boat before re-issuing lapsed liability insurance
but refused to re-issue lapsed comprehensive insurance because they
would have no way of knowing the initial condition of the boat. "But if
you inspect it for liability, then you would now...". Silence. "You
don't want to insure my boat, do you?" "No."
:)
kzo
On Sun, 04 Feb 2007 04:07:35 -0800, cadence wrote:
> Can someone tell me how to concatenate a list of symbols into a new
> symbol in
> common lisp?
> I'd like to take a list such as (ab cd ef gh) and generate the
> keyword :abcdefg,
> not knowing in advance whether such a keyword already exists.
>
> any suggestions?
> -jim
(defvar sym-list '(ab cd ef gh))
(defun symbol-conc (los &optional (package *package*))
(intern (apply #'concatenate 'string (mapcar #'symbol-name los)) package))
(symbol-conc sym-list 'keyword)
HTH, Ralf Mattes
cadence wrote:
> Can someone tell me how to concatenate a list of symbols into a new
> symbol in
> common lisp?
> I'd like to take a list such as (ab cd ef gh) and generate the
> keyword :abcdefg,
> not knowing in advance whether such a keyword already exists.
(intern
(with-output-to-string (s)
(loop for symbol in symbol-list
do (princ symbol s)))
:keyword)
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/