help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to convert a string to a symbol?


From: sunway
Subject: Re: how to convert a string to a symbol?
Date: Sun, 14 Sep 2008 00:10:33 -0700 (PDT)
User-agent: G2/1.0

I don't  want to take "(> 2 1)" as a symbol name, instead I want  "(>
2 1)" be evaled to 't'

On Sep 14, 2:10 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > > (setq str "(> 2 1)")
> > > I want something like: (eval (string-to-symbol str))
>
> > (intern str)
>
> And if you really want the value of the symbol (per your use of `eval' above):
>
> (symbol-value (intern str))
>
> But you might want to give it a value first ;-) -
>
> (set (intern "(> 2 1)") 42)
>
> (symbol-value '\(>\ 2\ 1\)) ; The answer is 42.
>
> However, as always with questions of this type, one wonders what you are
> _really_ trying to do (not to mention why)...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]