Newsgroups: comp.ai.alife,comp.ai.philosophy,comp.ai,alt.consciousness
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!news.alpha.net!uwm.edu!spool.mu.edu!howland.reston.ans.net!pipex!uknet!festival!edcogsci!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Subject: Re: Thought Question
Message-ID: <D45nB4.MEJ@cogsci.ed.ac.uk>
Sender: usenet@cogsci.ed.ac.uk (C News Software)
Nntp-Posting-Host: bute-alter.aiai.ed.ac.uk
Organization: AIAI, University of Edinburgh, Scotland
References: <3hg27i$gnd@xmission.xmission.com> <3hsv53$ipj@oznet03.ozemail.com.au> <3hu2u9$dde@romulus.rutgers.edu>
Date: Fri, 17 Feb 1995 17:30:38 GMT
Lines: 35
Xref: glinda.oz.cs.cmu.edu comp.ai.alife:2477 comp.ai.philosophy:25631 comp.ai:27566

In article <3hu2u9$dde@romulus.rutgers.edu> wclark@romulus.rutgers.edu (Bill Clark) writes:
>Alan Tonisson <tonisson@ozemail.com.au> writes:
>
>>Way back when I was studying at university, a computer science lecturer 
>>challenged us with the problem of either writing a computer program which 
>>prints its own source or proving that it could not be done.  I convinced 
>>myself that it was impossible because it must require some sort of infinite 
>>recursion, but couldn't prove it, but a friend of mine won the challenge and 
>>wrote a Pascal program which prints it's own source.  A few years later when 
>>I was bored I figured out how to do it and wrote one in C.
>
>>I figure that such a program models itself in some sense.
>
>Here's a C example:

Here's one in Common Lisp, which may be easier to grasp:

;;; Self-reproducing function

(defun v ()
  (let ((m '(subst m
                   '**
                   '(defun v () (let ((m '**)) **)))))
    (subst m
           '**
           '(defun v () (let ((m '**)) **)))))


There's also this:

  ((lambda (x) (list x (list (quote quote) x)))
    (quote (lambda (x) (list x (list (quote quote) x)))))

-- jeff

