From: Mark Conlin
Subject: Question about structure names
Date: 
Message-ID: <780du4$sjr@catapult.gatech.edu>
Trying to make a set of structures,

I want to give each one a name up to N like the following
e1, e2, e3, e4, e5 ... eN

I can use (concatenate 'string "e" (string (digit-char num))) to make
"e1", "e2", "e3" ....

This makes strings as I loop 

Is there a way to turn strings into variable names ?

So that I can (set "e1" (make-mystructure))



--
mec --gt2863a
 

From: Hrvoje Niksic
Subject: Re: Question about structure names
Date: 
Message-ID: <kigu2xoyy6y.fsf@jagor.srce.hr>
·······@acmex.gatech.edu (Mark Conlin) writes:

> Is there a way to turn strings into variable names ?

Use INTERN.

> So that I can (set "e1" (make-mystructure))

(set (intern "e1") (make-mystructure))
From: Christopher R. Barry
Subject: Re: Question about structure names
Date: 
Message-ID: <8790f0t97d.fsf@2xtreme.net>
Hrvoje Niksic <·······@srce.hr> writes:

> ·······@acmex.gatech.edu (Mark Conlin) writes:
> 
> > Is there a way to turn strings into variable names ?
> 
> Use INTERN.
> 
> > So that I can (set "e1" (make-mystructure))
> 
> (set (intern "e1") (make-mystructure))

You may want to uppercase the string first or do this any of a number
of other ways so that you may refer to your structures like 'e1
instead of '|e1|.

Christopher
From: Lyman S. Taylor
Subject: Re: Question about structure names
Date: 
Message-ID: <781540$52l@pravda.cc.gatech.edu>
In article <··········@catapult.gatech.edu>,
Mark Conlin <·······@acmex.gatech.edu> wrote:

>I want to give each one a name up to N like the following
>e1, e2, e3, e4, e5 ... eN

  Unless the particulars of the 1..N sequence are important you
  can also invoke: 

     (gentemp "E" )  

   N times.  If the E prefix isn't important they you can use no args. 
   [the default value is "T" ]. 


USER(3): (gentemp "E")
E0
NIL
USER(4): (gentemp "E")
E1
NIL

    Otherwise, as mentioned before,  upcased strings passed to INTERN
    will work. 

     If you merely wish to bind them to some symbols you can also look
     at GENSYM and MAKE-SYMBOL.  INTERN effectively inserts the symbol
     in the package. 





-- 
					
Lyman S. Taylor          "The Borg --  party poopers of the Galaxy. "
(·····@cc.gatech.edu)                 EMH Doctor  Star Trek Voyager. 
From: Marco Antoniotti
Subject: Re: Question about structure names
Date: 
Message-ID: <lwaezfwsuh.fsf@copernico.parades.rm.cnr.it>
·······@acmex.gatech.edu (Mark Conlin) writes:

> Trying to make a set of structures,
> 
> I want to give each one a name up to N like the following
> e1, e2, e3, e4, e5 ... eN
> 
> I can use (concatenate 'string "e" (string (digit-char num))) to make
> "e1", "e2", "e3" ....
> 
> This makes strings as I loop 
> 
> Is there a way to turn strings into variable names ?
> 
> So that I can (set "e1" (make-mystructure))
> 

Why do you want to do that in the first place?

If you know that you have N elements just do

(let ((es (make-array N)))
  (dotimes (i N)
    (setf (aref es i) (make-mystructure)))
  (defun e (i)
     (aref es i)))

Then you can always access the i-th structure by saying

	(do-something (e i))

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - (0)6 - 68 10 03 17, fax. +39 - (0)6 - 68 80 79 26
http://www.parades.rm.cnr.it