tut@cairo.Eng.Sun.COM (Bill "Bill" Tuthill) (02/26/91)
We have converted most of our documents from troff to FrameMaker, but I am unable to convert this Tower of Hanoi program written in troff. Could anyone supply the equivalent for FrameMaker or Interleaf? Thanks in advance. ================ .de T .nr d \\$1-1 .if \\nd .T \\nd \\$2 \\$4 \\$3 Transfer ring \\$1 from tower \\$2 to tower \\$3. .nr d \\$1-1 .if \\nd .T \\nd \\$4 \\$3 \\$2 .. Initial state: \nR rings all on tower A; #1 on top. .T \nR A B C Done! ================ $ troff -rR4 Initial state: 4 rings all on tower A; #1 on top. Transfer ring 1 from tower A to tower C. Transfer ring 2 from tower A to tower B. Transfer ring 1 from tower C to tower B. Transfer ring 3 from tower A to tower C. Transfer ring 1 from tower B to tower A. Transfer ring 2 from tower B to tower C. Transfer ring 1 from tower A to tower C. Transfer ring 4 from tower A to tower B. Transfer ring 1 from tower C to tower B. Transfer ring 2 from tower C to tower A. Transfer ring 1 from tower B to tower A. Transfer ring 3 from tower C to tower B. Transfer ring 1 from tower A to tower C. Transfer ring 2 from tower A to tower B. Transfer ring 1 from tower C to tower B. Done!
iau@ukc.ac.uk (I.A.Utting) (02/27/91)
Wonderful stuff. In a similar vein, did anyone keep the troff fragment which split mm/dd/yy into mm, dd and yy in separate number (string?) registers? Having enjoyed it then thrown it away, I've now got a real need for it! I know I could do it with .pi, but that's got no style. Ian.
edb@HQ.Ileaf.COM (Ed Blachman x4420) (03/01/91)
In article <8564@exodus.Eng.Sun.COM> tut@cairo.Eng.Sun.COM (Bill "Bill" Tuthill) writes (tongue-in-cheek, I assume): > We have converted most of our documents from troff to FrameMaker, > but I am unable to convert this Tower of Hanoi program written > in troff. Could anyone supply the equivalent for FrameMaker or > Interleaf? Thanks in advance. > > ================ > .de T > .nr d \\$1-1 > .if \\nd .T \\nd \\$2 \\$4 \\$3 > Transfer ring \\$1 from tower \\$2 to tower \\$3. > .nr d \\$1-1 > .if \\nd .T \\nd \\$4 \\$3 \\$2 > .. > Initial state: \nR rings all on tower A; #1 on top. > .T \nR A B C > Done! Here is a way to do this with Interleaf 5: (defun tower (depth a b c) (if (/= 0 (dec depth)) (tower depth a c b)) (format t " Transfer ring ~D from tower ~C to tower ~C.~%" (1+ depth) a b) (if (/= 0 depth) (tower depth c b a))) (defun do-tower (depth) (format t "~%Initial state: ~D rings all on tower A; #1 on top.~%" depth) (tower depth #\A #\B #\C) (format t " Done!")) (do-tower 4) The animated version, in which you see little rings lift themselves off of one pole and drop themselves onto another, is doable, if (we hope you'd agree) understandably not quite as terse. We hope this was what you were looking for.... ;^) -- ed Ed Blachman edb@ileaf.com Paul English pme@ileaf.com
Dan_Jacobson@ATT.COM (03/01/91)
>>>>> On 28 Feb 91 23:39:31 GMT, edb@HQ.Ileaf.COM (Ed Blachman x4420) said: Ed> Here is a way to do this with Interleaf 5: Ed> (defun tower (depth a b c) [...] "defun", Gee, that reminds me of GNU Emacs' version, which just left my screeen like: | | | | 000 | | 11111 | | 2222222 | =============================================================================== anyway, the sources are in hanoi.el in GNU Emacs. -- Dan_Jacobson@ATT.COM Naperville IL USA +1 708 979 6364
jeff@itx.isc.com (Jeff Copeland) (03/01/91)
Followup-To: comp.text Distribution: Organization: Interactive Systems Corp., Santa Monica, CA Keywords: In article <279@serval.ukc.ac.uk> iau@ukc.ac.uk (I.A.Utting) writes: >Wonderful stuff. > >In a similar vein, did anyone keep the troff fragment which split mm/dd/yy >into mm, dd and yy in separate number (string?) registers? Having enjoyed it >then thrown it away, I've now got a real need for it! I know I could do it >with .pi, but that's got no style. > >Ian. I don't know if this is the same one or not, but this is one of the variations I use when for documentation with RCS headers. .de DT\" get the date out of the RCS Header line .if !"\\$7"Locked" \{\ .tr / .de NR .br .nr yr \\\\$1 .nr mo \\\\$2 \\.. .di X \\!.NR \\$4 .di .X .rm X NR .tr // .\} .. .\" setup the date .DT $Header: rr,v 1.4 90/03/23 16:43:47 jeff Exp $ .ie \n(mo-11 \*TDecember, 19\n(yr .el .ie \n(mo-10 \*TNovember, 19\n(yr .el .ie \n(mo-9 \*TOctober, 19\n(yr .el .ie \n(mo-8 \*TSeptember, 19\n(yr .el .ie \n(mo-7 \*TAugust, 19\n(yr .el .ie \n(mo-6 \*TJuly, 19\n(yr .el .ie \n(mo-5 \*TJune, 19\n(yr .el .ie \n(mo-4 \*TMay, 19\n(yr .el .ie \n(mo-3 \*TApril, 19\n(yr .el .ie \n(mo-2 \*TMarch, 19\n(yr .el .ie \n(mo-1 \*TFebruary, 19\n(yr .el \*TJanuary, 19\n(yr So, if the file is locked, the DT macro does nothing, else it sets the mo and yr number registers, which are later used to print the date. If the file *is* locked, mo and yr have the values set on startup, which are the current month and year.
jaap@mtxinu.COM (Jaap Akkerhuis) (03/02/91)
In article <1991Feb28.233931.2615@HQ.Ileaf.COM> edb@HQ.Ileaf.COM (Ed Blachman) writes: > In article <8564@exodus.Eng.Sun.COM> tut@cairo.Eng.Sun.COM (Bill "Bill" Tuthill) writes (tongue-in-cheek, I assume): > > We have converted most of our documents from troff to FrameMaker, > > but I am unable to convert this Tower of Hanoi program written > > in troff. Could anyone supply the equivalent for FrameMaker or > > Interleaf? Thanks in advance. > > > > [etc.] > > Here is a way to do this with Interleaf 5: > > [silly lisp program removed] > agree) understandably not quite as terse. > > We hope this was what you were looking for.... ;^) > I would consider it cheating. It would be like calling a lisp program from troff with .sy lisp hanoi > hanoi.out and capture the result with .so hanoi.out
edb@HQ.Ileaf.COM (Ed Blachman x4420) (03/05/91)
In article <1991Mar1.191413.7453@mtxinu.COM> jaap@mtxinu.UUCP (Jaap Akkerhuis) writes: > In article <1991Feb28.233931.2615@HQ.Ileaf.COM> edb@HQ.Ileaf.COM (Ed Blachman) writes: > > In article <8564@exodus.Eng.Sun.COM> tut@cairo.Eng.Sun.COM (Bill "Bill" Tuthill) writes (tongue-in-cheek, I assume): > > > We have converted most of our documents from troff to FrameMaker, > > > but I am unable to convert this Tower of Hanoi program written > > > in troff. Could anyone supply the equivalent for FrameMaker or > > > Interleaf? Thanks in advance. > > > > > > [etc.] > > > > Here is a way to do this with Interleaf 5: > > > > [silly lisp program removed] > > agree) understandably not quite as terse. > > > > We hope this was what you were looking for.... ;^) > > > > I would consider it cheating. Excuse me? Did I miss a smiley here or something? Bill's Tower of Hanoi solution was an nroff macro; the one that Paul and I wrote was an Interleaf macro. It just happens that the Interleaf macro language is Interleaf lisp... but how does that make it cheating? > It would be like calling a lisp program from troff with > .sy lisp hanoi > hanoi.out > and capture the result with > .so hanoi.out Actually, I considered a solution of that sort: using Interleaf lisp to invoke troff (with Bill's input) as an external process. Now *that* would have been cheating... I guess. ;^) Ed Blachman edb@ileaf.com (or) ...!uunet!leafusa!edb
jaap@mtxinu.COM (Jaap Akkerhuis) (03/06/91)
In article <1991Mar4.163007.26085@HQ.Ileaf.COM> edb@HQ.Ileaf.COM (Ed Blachman) writes: > In article <1991Mar1.191413.7453@mtxinu.COM> jaap@mtxinu.UUCP (Jaap Akkerhuis) writes: > > In article <1991Feb28.233931.2615@HQ.Ileaf.COM> edb@HQ.Ileaf.COM (Ed Blachman) writes: > > I would consider it cheating. > > Excuse me? Did I miss a smiley here or something? Bill's Tower of Hanoi > solution was an nroff macro; the one that Paul and I wrote was an Interleaf > macro. It just happens that the Interleaf macro language is Interleaf > lisp... but how does that make it cheating? > Bless my ignorance, but last time (a year ago) I looked at Interleaf, it was using lisp as a language to program user extensions. It had as much to do with the text processing interleaf performs as, f.i. the shell has with troff. So that triggered my comment.