HELP ME....
I am desperately looking for a way to construct new symbols out of old
ones in Common Lisp. For instance "member" as an object should be returned
by "member-1" as an object. I figured I needed to make a string first out
of the input, then concatenate "-1", and finally translate this back into
a symbol.
These last two steps elude me however.
How do I concatenate two strings (i.e. "abc" + "def" becomes "abcdef")???
How do I get the symbol out of a string???
(i.e. "member-1" becomes MEMBER-1)
Thank you for your time,
----------------------------------------------------------------------------
P.A. Donker Faculty of Architecture University of Technology Delft
The Netherlands
EMail ·····@duteca.et.tudelft.nl Europe
----------------------------------------------------------------------------
In article <······················@donau.et.tudelft.nl> ·····@dutecai.et.tudelft.nl (;Leon Kemna) writes:
>How do I concatenate two strings (i.e. "abc" + "def" becomes "abcdef")???
Use the CONCATENATE function, of course!
(concatenate 'string "abc" "def") -> "abcdef"
>How do I get the symbol out of a string???
>(i.e. "member-1" becomes MEMBER-1)
There is no symbol "in" a string, so you can't get it "out". You can make
a symbol whose name is a string with MAKE-SYMBOL or INTERN (depending on
whether you want an uninterned or interned symbol).
Note that (make-symbol "member-1") will create |member-1|, not MEMBER-1.
Except for the reader, Common Lisp is case-sensitive; the reader normally
upcases characters as it reads them. If you'll simply be concatenating
"-1" onto the end of (symbol-name 'member) then the right thing will
happen, but if you're constructing symbols from scratch you have to be
aware of this behavior.
--
Barry Margolin, Thinking Machines Corp.
······@think.com
{uunet,harvard}!think!barmar
Date: Wed, 12 Feb 1992 20:05 EST
From: ";Leon Kemna" <·····@dutecai.et.tudelft.nl>
HELP ME....
I am desperately looking for a way to construct new symbols out of old
ones in Common Lisp. For instance "member" as an object should be returned
by "member-1" as an object. I figured I needed to make a string first out
of the input, then concatenate "-1", and finally translate this back into
a symbol.
These last two steps elude me however.
How do I concatenate two strings (i.e. "abc" + "def" becomes "abcdef")???
How do I get the symbol out of a string???
(i.e. "member-1" becomes MEMBER-1)
Read the descriptions of CONCATENATE and INTERN.
In article <······················@donau.et.tudelft.nl> ·····@dutecai.et.tudelft.nl (;Leon Kemna) writes:
Lines: 22
Nntp-Posting-Host: dutecai.et.tudelft.nl
HELP ME....
I am desperately looking for a way to construct new symbols out of old
ones in Common Lisp. For instance "member" as an object should be returned
by "member-1" as an object.
consider using a package just for these symbols. that way all you
have to do is put them into the new package, and you don't have to
worry about whether they conflict with pre-existing symbols in other
packages.
of course, this solution won't work in many cases, but if it does, it
will be very simple.
make sure that the object package doesn't use any other packages. you
can do this by doing a make-package with the right arguments.