Hi;
I am in need of a built in predicate that will convert a
string type to a symbol. For example if I have two lists as such:
(#\n #\a #\m #\e) (name)
I would like to be able to compare the two and the result of the
comparison should be true. In this current situation they are ob-
viously not the same. Is there an existing predicate that will
convert (#\n #\a #\m #\e) to (name) ? Your responses will be greatly
appreciated.
Thanks;
John G.
-------------------------------------------------------------------------
| ////////////////// University of California, Irvine |
| /// /// *************************************** |
| // /// /// \\// JOHN H GHADIMI---> ········@bonnie.ics.uci.edu |
| ////// \\\\\\\\ ·······@orion.oac.uci.edu |
| |
| "Everything Counts in Large Amounts" |
| DM |
-------------------------------------------------------------------------
In article <··················@Bonnie.ics.uci.edu>, ········@Bonnie.ICS.UCI.EDU
("John H. Ghadimi") writes:
|> Hi;
|> I am in need of a built in predicate that will convert a
|> string type to a symbol. For example if I have two lists as such:
|>
|> (#\n #\a #\m #\e) (name)
|>
|> I would like to be able to compare the two and the result of the
|> comparison should be true.
I'm not sure that this is what you were looking for, but if you want
to compare the two as strings:
(coerce '(#\n #\a #\m #\e) 'string)
and
(symbol-name 'name)
will turn both into strings, which you can then compare using STRING-EQUAL.
Remember that the symbol-name will, in general, be uppercase.
Bye,
Alberto Riva
···@ipvaim.unipv.it
Department of Computer and Systems Science
University of Pavia
Italy
In article <··················@Bonnie.ics.uci.edu> ········@Bonnie.ICS.UCI.EDU ("John H. Ghadimi") writes:
> I am in need of a built in predicate that will convert a
>string type to a symbol. For example if I have two lists as such:
MAKE-SYMBOL takes a string and returns an uninterned symbol with that name.
INTERN is similar but it interns the symbol. And FIND-SYMBOL will return
an existing interned symbol with the given name, or NIL to indicate that
there isn't one.
>(#\n #\a #\m #\e) (name)
>
>I would like to be able to compare the two and the result of the
>comparison should be true.
You don't need to convert a string to a symbol for this. You can compare a
string and a symbol using STRING= or STRING-EQUAL; they will use the name
of the symbol in the comparison.
(defun compare-char-list-to-symbol (char-list symbol-list)
(let ((string (make-array (length char-list) :element-type 'character
:initial-contents char-list))
(symbol (car symbol-list)))
(string-equal string symbol)))
--
Barry Margolin
System Manager, Thinking Machines Corp.
······@think.com {uunet,harvard}!think!barmar