From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: shorter form of frequently-seen lisp idiom? Date: Sun, 20 Feb 2005 00:55:53 +0100 Organization: Organization?!? Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1108857256 19777 80.91.229.2 (19 Feb 2005 23:54:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 19 Feb 2005 23:54:16 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 20 00:54:16 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D2eQB-0001pw-Bz for geh-help-gnu-emacs@m.gmane.org; Sun, 20 Feb 2005 00:53:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D2ego-00038U-U7 for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Feb 2005 19:11:10 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 36 Original-X-Trace: individual.net fAChfJQNr9DlHbVQCcVmWgw/VIEsFClvW9juCycKmuEtgEiSRx X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:jmR6PGTRxyM5F8CS7FmLr3NEoaY= Original-Xref: shelby.stanford.edu gnu.emacs.help:128654 Original-To: help-gnu-emacs@gnu.org 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 X-MailScanner-To: geh-help-gnu-emacs@m.gmane.org Xref: main.gmane.org gmane.emacs.help:24186 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:24186 August writes: > On lör, 2005-02-19 at 19:43 +0100, David Kastrup wrote: >> Joe Corneli writes: >> >> > Is there a shorter way to concatenate a list of strings >> > than this? >> > >> > (eval (append (list 'concat) list-of-strings)) >> > >> > Or more generally, >> > >> > (eval (append (list 'function-that-acts-on-foos) list-of-foos)) >> >> (apply #'concat list-of-strings) >> > > What's the purpose of the hash sign? `(apply 'concat > list-of-strings)' works too. 'concat is short for (quote concat), #'concat is short for (function concat). It tells the byte compiler that it is ok to compile the function. For example, '(lambda nil (if)) is a perfectly valid list and if used in function context even in compiled Elisp files, will be evaled the slow way at run time. #'(lambda nil (if)) in contrast gets byte-compiled (and the byte compiler will probably barf). -- David Kastrup, Kriemhildstr. 15, 44793 Bochum