home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / ada / 2150 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  1.9 KB

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