From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marc Tfardy Newsgroups: gmane.emacs.help Subject: Re: elisp - anonymous function in an association list? Date: Thu, 29 Nov 2007 15:50:45 +0100 Message-ID: <5r81u5F131t6qU1@mid.individual.net> References: <10f246a9-2a9b-477e-806d-7e3b38ce2607@i29g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196350887 26021 80.91.229.12 (29 Nov 2007 15:41:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Nov 2007 15:41:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 29 16:41:35 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 1IxlW6-0001yp-Pg for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 16:41:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IxlVr-00053b-7W for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 10:41:15 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Original-X-Trace: individual.net wjS5qaKz0FOZgDHqj5RbyQt7uekXwfuwASHk4PPIIhxndqOwyE Cancel-Lock: sha1:guNchH9CnT6bkOEYJNCV/8cR+uA= User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: <10f246a9-2a9b-477e-806d-7e3b38ce2607@i29g2000prf.googlegroups.com> Original-Xref: shelby.stanford.edu gnu.emacs.help:154256 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:49684 Archived-At: apatheticagnostic schrieb: > take, for example this code showing what I mean: > > (defvar sample-alist '(("a" '(lambda () > (message "We worked!"))) > ("b" #'(lambda () > (message "B worked too!"))))) > > (defun test-call (x) > (funcall (cdr (assoc x sample-alist)))) > > (test-call "a") > (test-call "b") > > Both calls fail, with an error message like so: This seems to work: (defvar sample-alist '(("a" (lambda () (message "We worked!"))) ("b" (lambda () (message "B worked too!"))))) (defun test-call (x) (funcall (eval (car (cdr (assoc x sample-alist)))))) (test-call "a") "We worked!" (test-call "b") "B worked too!" regards Marc