From: cadence
Subject: how to concatenate symbols
Date: 
Message-ID: <1170590855.338831.78560@a75g2000cwd.googlegroups.com>
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

From: cadence
Subject: Re: how to concatenate symbols
Date: 
Message-ID: <1170591695.369434.107030@m58g2000cwm.googlegroups.com>
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
From: Harald Hanche-Olsen
Subject: Re: how to concatenate symbols
Date: 
Message-ID: <pco7iuy5alz.fsf@shuttle.math.ntnu.no>
+ "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
From: Ken Tilton
Subject: [OT] Another one for the risk file...
Date: 
Message-ID: <qMlxh.7394$6E3.3647@newsfe10.lga>
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
From: Pascal Bourguignon
Subject: Re: how to concatenate symbols
Date: 
Message-ID: <87wt2yrn9f.fsf@thalassa.informatimago.com>
"cadence" <·····@rdrop.com> writes:

> Here is my attempt.  Is there an better way?
>
> (defun concat (list)
>   (intern (apply 'concatenate 'string (mapcar 'symbol-name list))
> 	  (find-package :keyword)))

FSVO "better":

(defun make-keyword-from-anything (list-of-anything)
   (intern (format nil "~{~A~}" list-of-anything) "KEYWORD"))

(MAKE-KEYWORD-FROM-ANYTHING '(abc- 123 "def" :ghi #(hip hip hip) (houra)))
--> :|ABC-123defGHI#(HIP HIP HIP)(HOURA)| ;
    NIL

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Specifications are for the weak and timid!"
From: Ralf Mattes
Subject: Re: how to concatenate symbols
Date: 
Message-ID: <pan.2007.02.04.12.43.40.510134@mh-freiburg.de>
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
From: Pascal Costanza
Subject: Re: how to concatenate symbols
Date: 
Message-ID: <52m2ukF1oe2ieU1@mid.individual.net>
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/