home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!uwm.edu!wupost!micro-heart-of-gold.mit.edu!uw-beaver!cs.ubc.ca!unixg.ubc.ca!msr.triumf.ca!asnd
- From: asnd@msr.triumf.ca (Donald Arseneau)
- Newsgroups: comp.text.tex
- Subject: Re: Boolean operators for TeX's \if constructions?
- Summary: Yes, but not pretty
- Message-ID: <7JAN199320223523@msr.triumf.ca>
- Date: 8 Jan 93 04:22:00 GMT
- References: <1993Jan3.150933.3089@wam.umd.edu>
- Organization: TRIUMF: Tri-University Meson Facility
- Lines: 41
- NNTP-Posting-Host: msr.triumf.ca
- News-Software: VAX/VMS VNEWS 1.41
-
- In article <1993Jan3.150933.3089@wam.umd.edu>, joel@wam.umd.edu (Joel M. Hoffman) writes...
- >Is there any way to incorporate boolean operators into TeX's \if
- >constructions? What I'd like to do is something like
- >
- > \if\a\b \and \if\a\c \or \if\a\d
- > \dosomething
- > \else
- > \dosomethingelse
- > \fi
- >
- >Any ideas?
-
- If you don't mind some very confusing constructs:
-
- AND:
- \ifnum 0\if\a\b \else 1\fi \if\a\c \else 1\fi=0 ...
- ------- -------
- OR:
- \ifnum 0\if\a\b 1\fi \if\a\c 1\fi >0 ...
- ------- -------
- EOR:
- \ifnum \if\a\b -\fi \if\a\c -\fi 1<0 ...
- ------- -------
-
- In these, the underlined parts are the tests to be ANDed or ORed. They
- end with a space after the 0. They can be extended to combining more than
- two tests at a time ( a or b or c or d ).
-
- So for the example: if (a=b and a=c) or a=d then
-
- \ifnum 0% for the outer "or", the next line is the first test, the inner "and"
- \ifnum 0\if\a\b \else 1\fi \if\a\c \else 1\fi=0 % note space at end
- \else 1\fi
- \if\a\d % the second test of the OR, simply compare a and d
- 1\fi >0 % another trailing space
-
- You could make macros \Land, \Lor to hide the mess, but they could not be
- skipped in conditional text unless there were equal ifs and fis visible.
-
-
- Donald Arseneau asnd@reg.triumf.ca
-