(元ネタ? →じゃあ this の抜き打ちテストやるぞー)
なんか JavaScript の this は難しいらしいな。でも、\if なんて TeX プログラミングの基礎の基礎の話だから、普段 TeX コードを書いてる人だったら \if はみんなばっちりだよな。じゃあ今から抜き打ちテストするぞー。
plain TeX または LaTeX において、起動直後に以下のコードを実行したとする。
\let\a=a \let\b=a \def\c{c} \chardef\d=`d \let\primA\indent \chardef\chardefA=42 \newcount\countA \countA=42 \def\macroA{42} \def\empty{} \let\X\relax \catcode`\X=13 \def X{c} \catcode`\Y=13 \let Y=c \catcode`\Z=13 \let Z\advance \catcode`\&=13 \let &\expandafter \catcode`\?=13 \let ?\undefinedA(
\undefinedAと\undefinedBは当然未定義です)この状態において、以下に挙げる
\if文の各々について、条件判定結果が真と偽の何れになるかを答えよ。
\if a\a\if b\b\if \a\b\if 42\if c\c\if ""\if \empty{}\if \indent\noindent\if \countA\chardefA\if \empty\macroA\if a\noexpand\a\if b\noexpand\b\if c\noexpand\c\if \primA\noexpand\macroA\if \noexpand\empty\noexpand\macroA\if \noexpand'\string'\if \noexpand\undefinedA\noexpand\undefinedB\if \noexpand$\relax\if \noexpand\macroA\countA\if \noexpand\c\noexpand\undefinedA\if \noexpand\undefinedB\noexpand\a\if d\d\if XY\if \string X\noexpand X\if \noexpandY\stringY\if \noexpandX\relax\if \noexpandX\c\if \noexpandX\noexpand\c\if \noexpandX\chardefA\if \noexpandYc\if \noexpandY\primA\if \noexpandY\string c\if \noexpandY\countA\if \noexpandZ\multiply\if \noexpandZ\noexpand\undefinedA\if \noexpandZ\stringZ\if \noexpand&\noexpand\futurelet\if \noexpand&\noexpand\undefinedA\if \noexpand&\string&\if \noexpand?\noexpand\undefinedB\if \noexpandX\noexpandY\if \noexpand?\noexpand&
評価は以下の通り。
| 正答数 | 評価 |
|---|---|
| 〜23 | 幸せな LaTeX ユーザ |
| 24〜29 | \if 初心者 |
| 30〜35 | \if 初級者 |
| 36〜41 | \if マスター |
| 42 | \if 芸人 |