Language: LISP (or Scheme) Author: Unknown Notes: There are several silly examples like this. T Author: Steven M. Haflich Note common LISP only #1=(WRITE '#1# :CIRCLE T) Author: Peter Norvig #1=(setq *print-circle* '#1#) Author: Unknown Note: only works if print-circle is defined #1='#1# Author: Peter Norvig Note: common LISP, self evaluating #1=((lambda () (setq *print-circle* '#1#))) Author: Chris Hruska ((LAMBDA (X) (LIST X (LIST 'QUOTE X))) '(LAMBDA (X) (LIST X (LIST 'QU OTE X)))) Author: Dave Seaman (ags@seaman.cc.purdue.edu) (let ((p "(let ((p ~s)) (format t p p))")) (format t p p)) Author: Sam Steingold (let ((a '(list 'let (list (list 'a (list 'quote a))) a))) (list 'let (list (list 'a (list 'quote a))) a)) Author: Sam Steingold (let ((a '(list 'let (list (list 'a (list 'quote a))) a))) `(let ((a (quote ,a))) ,a)) Author: Unknown ((lambda (x) (list x x)) (lambda (x) (list x x))) Author: Joe Miller Notes: In Common Lisp this should actually evaluate to the above list. In some dialects, however, it evaluates to itself. ((LAMBDA (X) `(,X ',X)) '(LAMBDA (X) `(,X ',X))) Author: Peter Norvig ((lambda (x) (list `',x)) '(lambda (x) (list x `',x))) Author: Unknown Note: common LISP ((lambda (list) (list list `',list)) '(lambda (list) (list list `',list))) Author: John McCarthy(creator of the language) and Carolyn Talcott ((lambda (x) (list x (list (quote quote) x))) (quote (lambda (x) (list x (list (quote quote) x))))) Author: John Burger, David Brill, Filip Machi (PRINTME (LAMBDA NIL (PROG (A B) (SETQ A (QUOTE (PRINTME (LAMBDA NIL (PROG (A B) (SETQA (QUOTE FOO)) (SETQ B (COPY A)) (RPLACA (CDADDR (CADDAR (CDDADR B)))A) (SETQ B (COPY A)) (RPLACA (CDADDR (CADDAR (CDDADR B))) A) (RETURN B)))) Author: Louise Hay Note: Result of her quine-generating program ((LAMBDA NIL ((LAMBDA (Y) (LIST (LIST (QUOTE LAMBDA) NIL (LIST Y (LIST (QUOTE QUOTE) Y))))) (QUOTE (LAMBDA (Y) (LIST (LIST (QUOTE LAMBDA) NIL (LIST Y (LIST (QUOTE QUOTE) Y))))))))) Author: Pekka P. Pirinen Notes: This is a self-printing expression in the format sublanguage. It works by using the ~:* directive to back up in the argument list and reuse the previous argument; this is how it manages to use the same string to format the new expression and print a copy of itself inside the new expression. Some CLs have a bug in the ~@? recursive format directive that prevents backing up beyond the control string argument, but the standard implies it ought to work. Tested in LispWorks 4.2 on Unix. (format t "~@?" "(format t \"~~@?\" ~:*~S)") Authors: Paul Bratley and Jean Millo define(( (c (prog (a) (print (quote define)) (print (list(list(list(quote c) (get(quote c) (quote expr)))))) (print (quote c)) (print (list a)) (print (quote stop)) (print (quote fin)))))) c(nil) stop fin Author: Olin.Shivers@cosmos.vlsi.cs.cmu.edu ((lambda (lambda) `(,lambda ',lambda)) '(lambda (lambda) `(,lambda ',lambda)))