summaryrefslogtreecommitdiff
path: root/info/challenges/aro-bend/exercise.001
blob: 589c94f120884937680ec10123f3d57748172d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
[Exercises 1,2,3 were originally posted together on 10 Oct 91]
Date: Thu 10 Oct 91 09:51:32-EST
From: Michael Downes <MJD@MATH.AMS.COM>
Subject: Around the bend
To: info-tex@shsu.edu

Proposal for a regular feature:

  AROUND THE BEND

With the encouragement of George Greenwade (the INFO-TeX list owner), I
would like to propose a regular department for INFO-TeX, called `Around
the bend'. It will consist of macro-writing challenges on the level of
the dangerous-bend exercises in the TeXbook, with interested parties
invited to collaborate and/or compete to find the best solution. My
motivation for doing this is partly selfish: to get more feedback from
other macro writers about some of the interesting macro-writing
problems that I run into.

I originally approached George for advice about setting up a separate
mailing list, but he thought that INFO-TeX and comp.text.tex readers
would be interested. Since INFO-TeX mail is also channeled to
comp.text.tex, readers of the latter should let me know if they don't
want the extra traffic (although I don't expect it to be that much). I
don't currently have access to read comp.text.tex directly, although
George has been investigating the possibility of piping it through the
INFO-TeX mailing list. So if you object by posting to comp.text.tex, I
may not see your objection; send me mail, instead.

The sample below should give a pretty good idea of what `Around the
bend' would be like. Solutions should be sent to me instead of to
INFO-TeX or comp.text.tex, on the premise that people usually won't want
to read others' solutions until they've had a chance to try their own
hand. A summary of the results would then be posted to the INFO-TeX
list after two or three weeks; to those who submit solutions before the
deadline, I could forward without delay solutions submitted by other
people, for comparison.

I will try to keep the difficulty of the exercises down to something
reasonable, let's say, on the level of a homework assignment which a
university student must complete in two weeks, finding time in the
normal way from the usual busy schedule of other homework, class
attendance, sports, and social life. However, be warned that the
challenges will be hard. I'm planning to follow a `hard and fast'
format: one or two hard questions, followed by one or two fast
questions, where if you don't know the answer off the top of your head,
you can either look it up in the TeXbook or find it by running a quick
test.

All right, here are the first three.

**********************************************************************
*** Exercise 1 (hard):
Given arbitrary \b, \c, \d (macros without arguments), for example

       \def\b{\c\c}         \def\c{*}            \def\d{\b\c}

figure out how to define \a so that its replacement text consists
of \b fully expanded plus \c not expanded plus \d expanded exactly once.
I.e., with the above definitions the replacement text of \a
should be 

       **\c\b\c

You may not use \the or \noexpand in your solution. This is Exercise
20.16 in the TeXbook, except that there's an added restriction: your
answer must also not use the \halign ... \span method given in the
answer to 20.16. (Yes, that means you can't use \valign either!)

Why would anyone want to do such a hard exercise? Answer: advanced
macro writing requires a thorough knowledge of expansion control
principles.

[Exercise 2 moved to exercise.002]
[Exercise 3 moved to exercise.003]

Send answers to:

Michael Downes      mjd@math.ams.com (Internet)

A summary will be posted Friday, October 25, 1991.