Subject: Re: Lambda Quine (and the Lisp it rode in on)
From: (Rob Warnock)
Date: Sat, 09 Oct 2004 04:00:02 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Joel Ray Holveck  <> wrote:
| While bored one night, I thought about how a lot of people only
| know one thing about Lisp: that it uses lots of parens.  If they've
| taken a class in college that uses Lisp, they may also remember that
| it's got "some weird funky lambda thing".
| So I decided to implement a quine (I was reading GEB at the time)
| using only parens and lambda, no other tokens:
| ((lambda (lambda) ((lambda lambda lambda) lambda lambda))
|  (lambda (lambda) ((lambda lambda lambda) lambda lambda)))
| (I seem to recall a discussion here about "Buffalo buffalo buffalo
| buffalo buffalo."  It may have been related to this quine.)
| Now, this is (I believe) correct for *some* definition of Lisp, but it
| has some requirements on the Lisp...

Here's a REPL quine that Kent Pitman posted several years ago
[in <>] that works in ANSI CL:

    (LET ((LET
	   '`(LET ((LET ',LET))
      `(LET ((LET ',LET))

By using the standard expansion of LET into LAMBDA:

    (let ((var value))   ==>  ((lambda (var) body)
      body)                     value)

and possibly some local variable renaming (of quoted constant
symbol LETs into symbol LAMBDAs), you should be able to transform 
the all LETs & quotes & backquotes version in a LAMBDAs & quotes &
backquotes version, but I'm not sure you can get rid of the
quotes & backquotes.

Here's my first cut at a conversion of the above LET-based quine
into LAMBDAs & quotes & backquotes. I may have made mistakes in
the conversion, but at least the result *is* a REPL quine in CL
[well, at least in both CMUCL & CLISP]:



Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607