Skip to main content
Slightly less characters
Source Link
Bruno Le Floch
  • 1.3k
  • 10
  • 13

eTeX, 218201 characters (not counting the two irrelevant linebreaks)

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1   {\ifcsname-#1##1~\D\else\if\csname-#1##1~\fi+#2\fi}}~70 ~80~90~0{10#1##1 ~\D\fi\if\csname#1##1 ~\fi+"#2}~U2~O3~K4~D{11}\global\let~\endcsname\def\a~70~80~90~0A~U2~O3~K4~DB\def [#1]\a[#1]{\write6\let~\endcsname\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.

EDIT: as allowed in the statement of the question, incorrect input can cause (an) error. For instance, etex filename.tex [OK] crashes horribly (because K is not a valid color).

eTeX, 218 characters

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1  {\ifcsname-#1##1~\D\else\if\csname-#1##1~\fi+#2\fi}}~70 ~80~90~0{10}~U2~O3~K4~D{11}\global\let~\endcsname\def\a [#1]{\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.

EDIT: as allowed in the statement of the question, incorrect input can cause (an) error. For instance, etex filename.tex [OK] crashes horribly (because K is not a valid color).

eTeX, 201 characters (not counting the two irrelevant linebreaks)

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1 {\ifcsname #1##1 ~\D\fi\if\csname#1##1 ~\fi+"#2}}~70~80~90~0A~U2~O3~K4~DB\def \a[#1]{\let~\endcsname\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.

EDIT: as allowed in the statement of the question, incorrect input can cause (an) error. For instance, etex filename.tex [OK] crashes horribly (because K is not a valid color).

Explained that errors are horrible.
Source Link
Bruno Le Floch
  • 1.3k
  • 10
  • 13

eTeX, 218 characters

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1 {\ifcsname-#1##1~\D\else\if\csname-#1##1~\fi+#2\fi}}~70 ~80~90~0{10}~U2~O3~K4~D{11}\global\let~\endcsname\def\a [#1]{\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.

EDIT: as allowed in the statement of the question, incorrect input can cause (an) error. For instance, etex filename.tex [OK] crashes horribly (because K is not a valid color).

eTeX, 218 characters

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1 {\ifcsname-#1##1~\D\else\if\csname-#1##1~\fi+#2\fi}}~70 ~80~90~0{10}~U2~O3~K4~D{11}\global\let~\endcsname\def\a [#1]{\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.

eTeX, 218 characters

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1 {\ifcsname-#1##1~\D\else\if\csname-#1##1~\fi+#2\fi}}~70 ~80~90~0{10}~U2~O3~K4~D{11}\global\let~\endcsname\def\a [#1]{\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.

EDIT: as allowed in the statement of the question, incorrect input can cause (an) error. For instance, etex filename.tex [OK] crashes horribly (because K is not a valid color).

Source Link
Bruno Le Floch
  • 1.3k
  • 10
  • 13

eTeX, 218 characters

\def~#1#2{\catcode`#113\lccode`~`#1\lowercase{\def~}##1 {\ifcsname-#1##1~\D\else\if\csname-#1##1~\fi+#2\fi}}~70 ~80~90~0{10}~U2~O3~K4~D{11}\global\let~\endcsname\def\a [#1]{\write6{^^J \the\numexpr#1 }\end}\expandafter\a 

Used as etex filename.tex [UA OB DL KH]. Putting the argument in brackets is necessary: otherwise, eTeX has no way of determining that we reached the end of the argument list.