* Define doifoneelse
@ 2006-09-11 4:45 Aditya Mahajan
2006-09-11 5:57 ` Aditya Mahajan
2006-09-11 9:57 ` Peter Münster
0 siblings, 2 replies; 5+ messages in thread
From: Aditya Mahajan @ 2006-09-11 4:45 UTC (permalink / raw)
Hi,
I want to define a macro, \doifoneelse, that checks if the first
argument is 1 or not. It should work for decimals and strings also.
So,
\doifoneelse{1}{a}{b} gives a
\doifoneelse{1.5}{a}{b} gives b
\doifonelese{string}{a}{b} gives b
Can someone suggest how to define this?
Thanks,
Aditya
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Define doifoneelse
2006-09-11 4:45 Define doifoneelse Aditya Mahajan
@ 2006-09-11 5:57 ` Aditya Mahajan
2006-09-11 9:57 ` Peter Münster
1 sibling, 0 replies; 5+ messages in thread
From: Aditya Mahajan @ 2006-09-11 5:57 UTC (permalink / raw)
On Mon, 11 Sep 2006, Aditya Mahajan wrote:
> Hi,
>
> I want to define a macro, \doifoneelse, that checks if the first
> argument is 1 or not. It should work for decimals and strings also.
> So,
>
> \doifoneelse{1}{a}{b} gives a
> \doifoneelse{1.5}{a}{b} gives b
> \doifonelese{string}{a}{b} gives b
>
> Can someone suggest how to define this?
Ah, it is already defined in context. I was so fixated upon using
\ifnum and \ifcase that I did not see \doifelse. Sorry about the
noise.
Aditya
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Define doifoneelse
2006-09-11 4:45 Define doifoneelse Aditya Mahajan
2006-09-11 5:57 ` Aditya Mahajan
@ 2006-09-11 9:57 ` Peter Münster
2006-09-11 16:14 ` Aditya Mahajan
1 sibling, 1 reply; 5+ messages in thread
From: Peter Münster @ 2006-09-11 9:57 UTC (permalink / raw)
On Mon, 11 Sep 2006, Aditya Mahajan wrote:
> \doifoneelse{1}{a}{b} gives a
> \doifoneelse{1.5}{a}{b} gives b
> \doifonelese{string}{a}{b} gives b
>
> Can someone suggest how to define this?
\def\doifoneelse#1#2#3{\doifelse{1}{#1}{#2}{#3}}
\starttext
\doifoneelse{1}{a}{b} gives a
\doifoneelse{1.5}{a}{b} gives b
\doifoneelse{string}{a}{b} gives b
\stoptext
Cheers, Peter
--
http://pmrb.free.fr/contact/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Define doifoneelse
2006-09-11 9:57 ` Peter Münster
@ 2006-09-11 16:14 ` Aditya Mahajan
2006-09-11 19:11 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2006-09-11 16:14 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed, Size: 433 bytes --]
On Mon, 11 Sep 2006, Peter Münster wrote:
> On Mon, 11 Sep 2006, Aditya Mahajan wrote:
>
>> \doifoneelse{1}{a}{b} gives a
>> \doifoneelse{1.5}{a}{b} gives b
>> \doifonelese{string}{a}{b} gives b
>>
>> Can someone suggest how to define this?
>
> \def\doifoneelse#1#2#3{\doifelse{1}{#1}{#2}{#3}}
Thanks Peter,
I ended up using
\def\doifoneelse#1{\doifelse{#1}{1}}
which saves a few keystrokes :)
Aditya
[-- Attachment #2: Type: text/plain, Size: 139 bytes --]
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Define doifoneelse
2006-09-11 16:14 ` Aditya Mahajan
@ 2006-09-11 19:11 ` Hans Hagen
0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2006-09-11 19:11 UTC (permalink / raw)
Aditya Mahajan wrote:
>
>
> On Mon, 11 Sep 2006, Peter M�nster wrote:
>
>> On Mon, 11 Sep 2006, Aditya Mahajan wrote:
>>
>>> \doifoneelse{1}{a}{b} gives a
>>> \doifoneelse{1.5}{a}{b} gives b
>>> \doifonelese{string}{a}{b} gives b
>>>
>>> Can someone suggest how to define this?
>>
>> \def\doifoneelse#1#2#3{\doifelse{1}{#1}{#2}{#3}}
>
> Thanks Peter,
>
> I ended up using
>
> \def\doifoneelse#1{\doifelse{#1}{1}}
>
> which saves a few keystrokes :)
\def\doifoneelse{\doifelse{1}}
or
\def\doifoneelse{\doifelse1}
saves you even more keystrokes and also a bit of runtime (measured in nanoseconds)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-09-11 19:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-11 4:45 Define doifoneelse Aditya Mahajan
2006-09-11 5:57 ` Aditya Mahajan
2006-09-11 9:57 ` Peter Münster
2006-09-11 16:14 ` Aditya Mahajan
2006-09-11 19:11 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).