Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!chalmers.se!cs.chalmers.se!jeffrey From: jeffrey@cs.chalmers.se (Alan Jeffrey) Newsgroups: comp.text.tex Subject: Re: (Another) puzzler for wannabe wizards Keywords: Dirty Tricks, catcode changing, puzzle Message-ID: <4651@undis.cs.chalmers.se> Date: 6 Jun 91 09:14:43 GMT References: Sender: news@cs.chalmers.se Distribution: comp Organization: Dept. of CS, Chalmers, Sweden Lines: 38 In article Bernd Raichle posed a horrible catcoding problem... > \catcode`\"=\active\gdef"{\"} > T"ater % output: T\"ater > \begingroup\catcode`\"=12 > \showthe\catcode`\" % print: 12 > % @ > \showthe\catcode`\" % print: 12 > T"ater % output: T''ater > \catcode`\"=\active > T"ater % output: T''ater > \endgroup > T"ater % output: T\"ater > \bye > At the place marked with @ there should be a > local(!) re-definition of the active char " Well, here's my solution---the only cheat is that it uses an extra auxilary definition, to swap the order of evaluation (I can't see any way to do this without something similar, as you need to give TeX's stomach the tokens "_13 then "_12 despite having read them in the order "_12 then "_13): \def\Swap#1#2{#2{#1}} And the contents of the gold envelope: \expandafter\Swap\expandafter{\the\catcode`\"\def#1{"}} {\catcode`\"\active\Swap}{\def"#1}\catcode`\""" Anyone got a solution that doesn't use \Swap or something similar? Alan. Alan Jeffrey Tel: +46 31 72 10 98 jeffrey@cs.chalmers.se Department of Computer Sciences, Chalmers University, Gothenburg, Sweden