cw (11/04/82)
An "introspective program" is one which prints out exactly its own source text when it executes. No tricks like looking for a core image or find the file and printing it are allowed. It is a theorem of recursive function theory that all sufficiently powerful automata have introspective programs; the definition of "sufficiently powerful" can be made precise and all reasonable programming languages (bar special compiler limitations) are powerful enough. I have written a rather nice version in FORTRAN; the problem is to get the required FORMAT statement out. C requires a similar solution because of the format string. A well-know Turing machine solution has (if memory serves) about 1700 states; I knew somebody who wrote them all out once. For slightly more information and many other interesting programming problems, may I refer you to Etudes for Programmers Charles Wetherell Prentice-Hall Feel free to buy a copy (it would be sufficient to have your company buy a copy for you); you won't hurt my feelings. Charles
stevenm (11/05/82)
A one-line introspective program. Beat this: main(){char q=34,n=10,*a="main(){char q=34,n=10,*a=%c%s%c;printf(a,q,a,q,n);}%c";printf(a,q,a,q,n);} S. McGeady Tektronix, Inc.