Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.psc.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!agate!howland.reston.ans.net!newsfeed.internetmci.com!news.sprintlink.net!in2.uu.net!netnews.jhuapl.edu!aplcenmp!hall
From: hall@aplcenmp.apl.jhu.edu (Marty Hall)
Subject: Re: self-evaluating non-atomic forms
Message-ID: <DG6Mzw.8DC@aplcenmp.apl.jhu.edu>
Organization: JHU/APL AI Lab, Hopkins P/T CS Faculty
References: <453r6i$448@kernighan.cs.umass.edu>
Date: Mon, 9 Oct 1995 13:04:44 GMT
Lines: 37

In article <453r6i$448@kernighan.cs.umass.edu> bhorowit@kerits.cs.umass.edu (Benjamin Horowitz) writes:
>I was recently asked the following question on a homework assignment:
>
>What is the shortest self-reproducing non-atomic LISP form?  [...]
>The professor's solution was as follows:
>
>((lambda (x) (list x (list 'quote x)))
>   '(lambda (x) (list x (list 'quote x))))
>
>My solution, which was shorter, was:
>
>((lambda (x) `(,x ',x) '(lambda (x) `(,x ',x)))  ; minor typo-missing paren
>
>My question is: can anyone come up with an even shorter self-
>evaluating non-atomic LISP form?

I give the same problem, and the above is the canonical answer. I
would consider "both" solutions above to be the same. (Note that this is
just (\x.xx)(\x.xx) in lambda calculus notation).

A few "cheating" answers that are shorter:

(A) Use the '-' variable. Infinite short solutions with it. Eg
-                  ; Certainly the shortest possible solution :-)
(first (list -))
(append - nil)
etc

(B) Type (print (read)) twice. You get back (print (read)) twice.
Definitely not self-evaluating, but kinda looks like it.

(C) If the professor foolishly says that the solution must be a list
instead of saying it is non-atomic, then NIL is a solution.

Cheers-
						- Marty
(proclaim '(inline skates))
