[texhax] question about \if

Uwe Lueck uwe.lueck at web.de
Fri Nov 12 12:36:58 CET 2010


"Heiko Oberdiek" <heiko.oberdiek at googlemail.com>, 12.11.2010 11:22:12:
>On Fri, Nov 12, 2010 at 05:31:13PM +1100, Vafa Khalighi wrote:
>
>> \newcommand{\test}[1]{\if#1t True\fi}
>> \test{t}
>> 
>> gives "True" as expected.
>> 
>> I want to change that so that \test{txys} gives "True" but I do not know
>> how?
>
> And what do you want to test?

Obviously, 

    \newcommand{\test}[1]{True}

satisfies the specification (maybe the most elegant from the countable infinite set of solutions). 

Hope this helps in some, may be indirect, way, and somebody joins me laughting ... sorry, this is humiliating ...

>> -- 
>> I prefer the most bloodcurdling death to living with humility.

... but fortunately, you are just afraid of being humble. 

Cheers, 

    Uwe. 


> And what do you want to test?
> * argument starts with `t',
> * after expansion the first token is `t',
> * the argument contains `t',
> * ...
> The context is important, are assigments allowed or is the
> test restricted to expandable contexts?
> ...
>
> Variant without expansion:
>
> \makeatletter
>  \newcommand{\test}[1]{%
>   \expandafter\ifx\expandafter t\@car#1XX\@nil
>    True%
>   \fi
> }
>\makeatother


More information about the texhax mailing list