In article <...> ·····@cs.bu.edu (Igor Sheyn) writes:
> What's the way to convert a single character string into a
> corresponding symbol ( i.e. \#d into `d )?
(intern (make-string 1 :initial-element #\d))
==> \d ;(A symbol with print-name of lower-case D!)
(intern (make-string 1 :initial-element (char-upcase #\d)))
==> D ;(A symbol with print-name of upper-case D!)
If you don't want the symbol interned, then use make-symbol instead of
intern.
Also, why do you want to do this in the first place?
--
________________________________________________________________________
Thomas A. Russ, USC/Information Sciences Institute ···@isi.edu
4676 Admiralty Way, Marina del Rey, CA 90292 (310) 822-1511x775
In article <··········@news.bu.edu> ·····@cs.bu.edu (Igor Sheyn) writes:
>What's the way to convert a single character string into a
>corresponding symbol ( i.e. \#d into `d )?
(defun char-symbol (char)
(make-symbol (make-string 1 :initial-element char)))
Note that this will make the symbol #:|a|, since it doesn't intern the
symbol and it doesn't change the case of the character. You can replace
MAKE-SYMBOL with INTERN if you want an interned symbol, and you can use
CHAR-UPCASE to force it to canonicalize the case of the character
(actually, you should probably make it check the READTABLE-CASE state).
--
Barry Margolin
System Manager, Thinking Machines Corp.
······@think.com {uunet,harvard}!think!barmar
In article <············@early-bird.think.com> ······@think.com (Barry Margolin) writes:
In article <··········@news.bu.edu> ·····@cs.bu.edu (Igor Sheyn) writes:
>What's the way to convert a single character string into a
>corresponding symbol ( i.e. \#d into `d )?
(defun char-symbol (char)
(make-symbol (make-string 1 :initial-element char)))
How about (make-symbol (string char))?