elementary lisp variable == string
SL Baur
steve at xemacs.org
Sun Mar 15 01:15:35 EDT 2009
On Thu, Mar 12, 2009 at 10:46 AM, Uwe Brauer <oub at mat.ucm.es> wrote:
>>>>>> "Sean" == Sean MacLennan <seanm at seanm.ca> writes:
>
> > On Thu, 12 Mar 2009 17:05:43 +0100
> > Uwe Brauer <oub at mat.ucm.es> wrote:
>
> >> Now in a function I want to execute certain code
> >>
> >> - if isp is indeed the string "hallo" and
> >>
> >> - if isp is the string "test" then another part of the code
> >> will be executed.
>
> > string= is your friend!
> (defvar isp "hallo" )
>
> > (if (string= isp "hallo") (message "hallo"))
>
> I presumed it would be simple, but this simple!
> Thanks
He said "simple". Heh, heh, heh, heh. `string=' is
typed. To be completely defensive against users
who will (setq isp 3.1415926) ; Happy National PI Day!
you need a guard as in:
(when (and (stringp isp) (string= isp "hallo"))
(message "hallo"))
-sb
More information about the XEmacs-Beta
mailing list