From: Thomas Rivas
Subject: shortest non-atomic Lisp form?
Date: 
Message-ID: <HWQIa.620$mc4.500@fe01.atl2.webusenet.com>
Hello --

Newbie question -- What is the shortest self-producing non-atomic Lisp 
form? -- I believe this is called a quine. I assume it uses a lambda 
expression. Thanks.

Thomas Rivas

From: Nick Levine
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <8732fc48.0306210143.1cb2d949@posting.google.com>
> Newbie question -- What is the shortest self-producing non-atomic Lisp 
> form? -- I believe this is called a quine. I assume it uses a lambda 
> expression. Thanks.

An old chestnut. "Uses lambda" is the standard hint that goes with it.
Now, this wouldn't be a homework assignment, would it?

Intersting extension: The solution that I am aware of is two lines of
code. I would be curious to know if there are longer solutions (a
family of them perhaps)? Any thoughts on this?

- nick
From: Eric Hanchrow
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <87vfuzzgu1.fsf@blarg.net>
http://www.eleves.ens.fr:8080/home/madore/computers/quine.html
-- 
Wasting programmer time is the true inefficiency, not wasting machine time.
        -- Paul Graham
From: Kent M Pitman
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <sfwisqzyint.fsf@shell01.TheWorld.com>
Thomas Rivas <·······@rawbw.com> writes:

> Hello --
> 
> Newbie question -- What is the shortest self-producing non-atomic Lisp
> form? -- I believe this is called a quine.

http://www.google.com/advanced_group_search

> I assume it uses a lambda expression. Thanks.

You can do it with LAMBDA.  It's prettier with just LET.

 (let ((let '`(let ((let ',let)) ,let)))
   `(let ((let ',let)) ,let))
From: Erann Gat
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <gat-2106031015510001@192.168.1.51>
In article <···············@shell01.TheWorld.com>, Kent M Pitman
<······@world.std.com> wrote:

> Thomas Rivas <·······@rawbw.com> writes:
> 
> > Hello --
> > 
> > Newbie question -- What is the shortest self-producing non-atomic Lisp
> > form? -- I believe this is called a quine.
> 
> http://www.google.com/advanced_group_search
> 
> > I assume it uses a lambda expression. Thanks.
> 
> You can do it with LAMBDA.  It's prettier with just LET.
> 
>  (let ((let '`(let ((let ',let)) ,let)))
>    `(let ((let ',let)) ,let))

Oh, I don't know.  I don't this this looks so bad:

((lambda (lambda)
  ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda)))
 '(lambda (lambda)
   ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda))))


;-)

(This one only works in Scheme of course.)

E.
From: Jon Allen Boone
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <m3llvv46vq.fsf@validus.delamancha.org>
···@jpl.nasa.gov (Erann Gat) writes:

> ((lambda (lambda)
>   ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda)))
>  '(lambda (lambda)
>    ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda))))
>
> ...
>
> (This one only works in Scheme of course.)

    I tried it with mit-scheme under Debian Gnu/Linux:

Scheme Microcode Version 14.9
MIT Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Scheme saved on Tuesday June 18, 2002 at 2:26:05 AM
  Release 7.7.1
  Microcode 14.9
  Runtime 15.1
  SF 4.40
  Liar (Intel i386) 4.115
  Edwin 3.112

1 ]=> ((lambda (lambda)
  ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda)))
 '(lambda (lambda)
   ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda))))

;The object (lambda (lambda) ((lambda lambda lambda) lambda ((lambda lambda lambda) (quote quote) lambda))) is not applicable.
;To continue, call RESTART with an option number:
; (RESTART 2) => Specify a procedure to use in its place.
; (RESTART 1) => Return to read-eval-print level 1.

--jon
-- 
------------------
IPmonger
········@delamancha.org
From: Erann Gat
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <gat-2106031430140001@192.168.1.51>
In article <··············@validus.delamancha.org>, Jon Allen Boone
<········@delamancha.org> wrote:

> ···@jpl.nasa.gov (Erann Gat) writes:
> 
> > ((lambda (lambda)
> >   ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda)))
> >  '(lambda (lambda)
> >    ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda))))
> >
> > ...
> >
> > (This one only works in Scheme of course.)
> 
>     I tried it with mit-scheme under Debian Gnu/Linux:
> 
> Scheme Microcode Version 14.9
> MIT Scheme running under GNU/Linux
> Type `^C' (control-C) followed by `H' to obtain information about interrupts.
> Scheme saved on Tuesday June 18, 2002 at 2:26:05 AM
>   Release 7.7.1
>   Microcode 14.9
>   Runtime 15.1
>   SF 4.40
>   Liar (Intel i386) 4.115
>   Edwin 3.112
> 
> 1 ]=> ((lambda (lambda)
>   ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda)))
>  '(lambda (lambda)
>    ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda))))
> 
> ;The object (lambda (lambda) ((lambda lambda lambda) lambda ((lambda
lambda lambda) (quote quote) lambda))) is not applicable.
> ;To continue, call RESTART with an option number:
> ; (RESTART 2) => Specify a procedure to use in its place.
> ; (RESTART 1) => Return to read-eval-print level 1.
> 
> --jon

It works in tinyscheme:

> ((lambda (lambda)
  ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda)))
 '(lambda (lambda)
   ((lambda lambda lambda) lambda ((lambda lambda lambda) 'quote lambda))))
((lambda (lambda) ((lambda lambda lambda) lambda ((lambda lambda lambda)
'quote lambda))) '(lambda (lambda) ((lambda lambda lambda) lambda ((lambda
lambda lambda) 'quote lambda))))

I think the problem is that it relies on lambda being a reserved word, and
there are no more reserved words in RnRS for some largish value of n.

E.
From: Coby Beck
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <bd30n2$to8$1@otis.netspace.net.au>
"Kent M Pitman" <······@world.std.com> wrote in message
····················@shell01.TheWorld.com...
> Thomas Rivas <·······@rawbw.com> writes:
>
> > Hello --
> >
> > Newbie question -- What is the shortest self-producing non-atomic Lisp
> > form? -- I believe this is called a quine.
>
> http://www.google.com/advanced_group_search
>
> > I assume it uses a lambda expression. Thanks.
>
> You can do it with LAMBDA.  It's prettier with just LET.
>
>  (let ((let '`(let ((let ',let)) ,let)))
>    `(let ((let ',let)) ,let))
>


Here are a bunch:
http://www.nyx.net/~gthompso/self_lisp.txt

which is the lisp link from this page:
http://www.nyx.net/~gthompso/quine.htm#languages


-- 
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Oudeis
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <9cca45d2.0306210603.d99bb40@posting.google.com>
I remember seeing one (and IIRC it used lambda) somewhere in CLTL II. 
--Oudeis.

Thomas Rivas <·······@rawbw.com> wrote in message news:<·················@fe01.atl2.webusenet.com>...
> Hello --
> 
> Newbie question -- What is the shortest self-producing non-atomic Lisp 
> form? -- I believe this is called a quine. I assume it uses a lambda 
> expression. Thanks.
> 
> Thomas Rivas
From: Christophe Rhodes
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <squ1ajubtb.fsf@lambda.jcn.srcf.net>
Thomas Rivas <·······@rawbw.com> writes:

> Newbie question -- What is the shortest self-producing non-atomic Lisp
> form? -- I believe this is called a quine. I assume it uses a lambda
> expression. Thanks.

#1='#1#

Cheers,

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)
From: Will Fitzgerald
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <QpaKa.1934$Vx2.993805@newssvr28.news.prodigy.com>
My favorite self-producing Common Lisp form has always been:

-

even though it's only  kinda sorta psuedo self-producing.

"The value of - is the form that is currently being evaluated by the Lisp
read-eval-print loop."
(http://www-2.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Body/var_-.html)
.

-Will Fitzgerald

"Thomas Rivas" <·······@rawbw.com> wrote in message
······················@fe01.atl2.webusenet.com...
> Hello --
>
> Newbie question -- What is the shortest self-producing non-atomic Lisp
> form? -- I believe this is called a quine. I assume it uses a lambda
> expression. Thanks.
>
> Thomas Rivas
>
>
From: Kaz Kylheku
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <cf333042.0306251329.41fb37f6@posting.google.com>
"Will Fitzgerald" <·················@ameritech.net.no.spam.please> wrote in message news:<·····················@newssvr28.news.prodigy.com>...
> My favorite self-producing Common Lisp form has always been:
> 
> -
> 
> even though it's only  kinda sorta psuedo self-producing.

I think what you mean is that there is no logic of self-production
inherent in the form itself; it only triggers a specific mechanism
that is embodied in the language, and that is specific to the task of
reproduction.

Kind of like:

  ``Give me tiny disk, no bigger than half an inch in diameter, that,
    when interpreted on a suitable machine, reproduces the music
    of Elvis''.

  ``Okay, here is a nickel for jukebox''.

Of course any self-rep program will need to trigger mechanisms in the
language, but those have to be nonspecific to the self-rep
action---certainly not a single, high-level ``reproduce me''
directive. There has to be an element of surprise in how the machine's
mechanisms are subdued to the task of self-reproduction.
From: Coby Beck
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <bdbgkf$16ro$1@otis.netspace.net.au>
"Will Fitzgerald" <·················@ameritech.net.no.spam.please> wrote in
message ··························@newssvr28.news.prodigy.com...
> My favorite self-producing Common Lisp form has always been:
>
> -
>
> even though it's only  kinda sorta psuedo self-producing.
>

here's an inspiration from the above that gets around the "non-atomic"
clause:

(car (list -))

...I like that!

-- 
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Adam Warner
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <pan.2003.06.25.08.40.54.334619@consulting.net.nz>
Hi Coby Beck,

>> My favorite self-producing Common Lisp form has always been:
>>
>> -
>>
>> even though it's only  kinda sorta psuedo self-producing.
>>
> 
> here's an inspiration from the above that gets around the "non-atomic"
> clause:
> 
> (car (list -))
> 
> ...I like that!

Neat. Does this qualify?: `,-

Regards,
Adam
From: Kalle Olavi Niemitalo
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <87vfuu2cqz.fsf@Astalo.kon.iki.fi>
Adam Warner <······@consulting.net.nz> writes:

> Does this qualify?: `,-

No, CMUCL reads it as - which is an atom.
From: Adam Warner
Subject: Re: shortest non-atomic Lisp form?
Date: 
Message-ID: <pan.2003.06.25.23.32.01.943857@consulting.net.nz>
Hi Kalle Olavi Niemitalo,

>> Does this qualify?: `,-
> 
> No, CMUCL reads it as - which is an atom.

Yet CLISP doesn't:

[1]> `,-
`,-

Is either result to be preferred?

Regards,
Adam
From: Kalle Olavi Niemitalo
Subject: representation of backquote (was: shortest non-atomic Lisp form?)
Date: 
Message-ID: <87llvmv997.fsf_-_@Astalo.kon.iki.fi>
Adam Warner <······@consulting.net.nz> writes:

> [1]> `,-
> `,-

CLISP 2.30 apparently represents that as:

  (SYSTEM::BACKQUOTE (SYSTEM::UNQUOTE -) -)

The second element of this list describes how the backquote
should be printed, and the third element is how it should be
macroexpanded.

Different systems read `(a ,@b c) in the following ways:

CLISP: (SYSTEM::BACKQUOTE (A (SYSTEM::SPLICE (SYSTEM::UNQUOTE B)) C)
                          (CONS (QUOTE A) (APPEND B (QUOTE (C)))))
CMUCL: (COMMON-LISP::BACKQ-CONS (QUOTE A)
                                (COMMON-LISP::BACKQ-APPEND B (QUOTE (C))))
Scheme: (quasiquote (a (unquote-splicing b) c))

CLISP and CMUCL parse the backquote at read time; Scheme does
that at macroexpand time.

> Is either result to be preferred?

I don't know.