home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!warwick!dcs.warwick.ac.uk!sunserver1.aston.ac.uk!cs_mac35.aston.ac.uk!user
- From: elsworthef@aston.ac.uk (Ted Elsworth)
- Newsgroups: comp.lang.ada
- Subject: Re: Shortest Self-Generating Ada Program
- Message-ID: <elsworthef-210792125545@cs_mac35.aston.ac.uk>
- Date: 21 Jul 92 12:03:17 GMT
- References: <1992Jul17.195827.18009@beaver.cs.washington.edu>
- Sender: usenet@aston.ac.uk (Usenet administrator)
- Followup-To: comp.lang.ada
- Organization: Computer Science, Aston University
- Lines: 36
- Nntp-Posting-Host: cs_mac35
-
- In article <1992Jul17.195827.18009@beaver.cs.washington.edu>,
- simonson@cs.washington.edu (Kevin Simonson) wrote:
- >
- > Quite a while ago I read a post in "comp.lang.c" about the shortest C
- > program that generated itself. The poster listed three programs, one of
- > which was only one line long but wider than eighty characters and another
- > of which was two lines long but more elegant.
- >
- > Trivial indeed, but ever since then I've wondered what it would look
- > like to write an Ada program that also generated itself. Here it is.
- > It's 100 lines long. If people can write Ada programs (elegant or not)
- > that take less lines, I'd be interested in seeing them.
- >
- > ---Kevin Simonson
- >
- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- >
- > (100 line Ada program)
-
- The following program *entered as one line* self-replicates using VAX Ada.
-
- with text_io;use text_io;procedure r is s:string(1..115):="with text_io;use
- text
- _io;procedure r is s:string(1..115):="";begin
- put(s(1..59)&s(1..59)&s(59..115)&s
- (59..115));end;";begin put(s(1..59)&s(1..59)&s(59..115)&s(59..115));end;
-
- Maximum source line length isn't specified by the Ada standard, but VAX Ada
- allows up to 255 characters, so the above (232 chars) works OK.
-
- Can anyone find a shorter solution than the above?
-
- Ted Elsworth
- Computer Science
- Aston University
- England
-