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

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

Re: Setting value 1 when matching two strings


From: Dr Rainer Woitok
Subject: Re: Setting value 1 when matching two strings
Date: Sun, 16 Oct 2022 18:23:14 +0200

Heime,

On Sunday, 2022-10-16 15:51:44 +0000, you wrote:

> This code sets "isel" to value "1" if "actm" matches "vert". I want to extend 
> this so that value "1"
> is also set when "actm" matches "horz".
> 
> (let ( (isel (if (equal "vert" actm) 1 -1)) )
> 
> Thus when "actm" matches "vert" or "horz", then "isel" has value "1". 
> Otherwise "isel" has value "-1".

In case you don't  really need "vert"  as a string but could as well use
the symbol 'vert,  you could use  "eq" rather than "equal".   And if you
want two or more alternatives, you could use

   (member actm '("vert" "horz"))

or

   (memq actm '(vert horz))

Sincerely,
  Rainer



reply via email to

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