Skip to content

Instantly share code, notes, and snippets.

@wtsnjp
Created October 18, 2018 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtsnjp/06018d0a9c5c91d50da3df2566b3add5 to your computer and use it in GitHub Desktop.
Save wtsnjp/06018d0a9c5c91d50da3df2566b3add5 to your computer and use it in GitHub Desktop.
% plain TeX
\catcode`@=11
\def\EvenOrOdd#1{\x@even@or@odd\empty #1\@nil}
\def\x@even@or@odd#1#2{%
\ifx#2\@nil
\x@hop@else\x@@even@or@odd #11\relax
\else
\x@hop@fi\x@even@or@odd{#1-}%
\fi}
\def\x@@even@or@odd#1\relax{\ifnum#1>\z@\expandafter E\else\expandafter O\fi}
\def\x@hop@else#1\else#2\fi{\fi #1}
\def\x@hop@fi#1\fi{\fi #1}
\edef\testA{\EvenOrOdd{a}:\EvenOrOdd{aa}:\EvenOrOdd{aaa}}
\expandafter\def\expandafter\testB\expandafter{%
\romannumeral-`>\EvenOrOdd{aaaa}}
\message{^^JTEST A: \meaning\testA}
\message{^^JTEST B: \meaning\testB}
\bye
% vim: ft=plaintex:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment