From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: (list) and '(list) Date: Thu, 26 Apr 2007 23:55:52 +0200 Organization: Informatimago Message-ID: <87k5vyol5j.fsf@thalassa.lan.informatimago.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1177626926 3581 80.91.229.12 (26 Apr 2007 22:35:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 26 Apr 2007 22:35:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 27 00:35:22 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HhCYZ-0007k2-08 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 00:35:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhCeK-0006FT-UT for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Apr 2007 18:41:16 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-X-Trace: individual.net SR/FJFpIx7wbA2Uu4/NQhgyJlIuWVtHrffmmXm+dxVzOZ64vhG Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux) Cancel-Lock: sha1:88aL0lyLsJoG3y9hDEb2O2hv35I= Original-Xref: shelby.stanford.edu gnu.emacs.help:147637 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:43240 Archived-At: A Soare writes: > Can somebody tell me if there already is a code that makes the > distintion between a list that evaluates as a function like > > (function ... > > and between a list that evaluates to itself : > > '(list ... , and its aliases like (quote (list ... etc A list that evaluates to itself? It cannot start with list. The function list returns a NEW list, so it will never return the source list itself. In your question, there's also a problem with the definition of 'itself'. Most quine programs (which are represented as lists, so they'd be candidates), don't return themselves (in the sense of eq), but themselves in the sense of equal. An easy way to know if the variable x is bound to a list that evaluates to itself in the sense of equal is: (and (listp x) (equal x (eval x))) For example: (let ((x '((lambda nil (let ((src "((lambda nil (let ((src %S)) (car (read-from-string (format src src))))))")) (car (read-from-string (format src src)))))))) (and (listp x) (equal x (eval x)))) --> t If you really want to test lists that give themselves in the sense of eq when evaluated, this restricts the number of such lists a lot, and you have to use #= and ## to write them: (let ((x '#1=((lambda nil (quote #1#))))) (and (listp x) (eq x (eval x)))) --> t Oh, and there is no way to know what a list evaluates to without effectively evaluating it, in general (testing whether the car of the list is list or function is evaluating it, at least partially. If you want an exact result, you'd need to evaluate it completely). -- __Pascal Bourguignon__ http://www.informatimago.com/ PLEASE NOTE: Some quantum physics theories suggest that when the consumer is not directly observing this product, it may cease to exist or will exist only in a vague and undetermined state.