From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.help Subject: Re: Break from a dolist Date: Sun, 09 Sep 2012 19:43:05 +0530 Message-ID: <874nn7l1xq.fsf@gmail.com> References: <87bohfy3om.fsf@Compaq.site> <87k3w3wec6.fsf@Compaq.site> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347199953 16172 80.91.229.3 (9 Sep 2012 14:12:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Sep 2012 14:12:33 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Cecil Westerhof Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 09 16:12:35 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TAiFW-00039g-Lu for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Sep 2012 16:12:34 +0200 Original-Received: from localhost ([::1]:49981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAiFT-0005vn-Al for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Sep 2012 10:12:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAiFL-0005up-KV for help-gnu-emacs@gnu.org; Sun, 09 Sep 2012 10:12:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAiFK-0003AK-ON for help-gnu-emacs@gnu.org; Sun, 09 Sep 2012 10:12:23 -0400 Original-Received: from mail-pz0-f41.google.com ([209.85.210.41]:40180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAiFK-0003A8-Hh for help-gnu-emacs@gnu.org; Sun, 09 Sep 2012 10:12:22 -0400 Original-Received: by dadi14 with SMTP id i14so868209dad.0 for ; Sun, 09 Sep 2012 07:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=DmYzfJxNhWCdWa+KywBSO8umxu1F2wEv1zHmIB7aTeg=; b=QmjKuRqMuOmm9Tf5f1Qe112rz6+nJBRkeMjfdAh9Obq8Ko6Bp/9GJqxEgxPYZ0f+nn POw9z4AjyR1kDkHuCRPw+NovoWdGnL9dP6aiqDjawUrgv6rbIN/zkWm07jFXe3hu25LL eDJPKc/lmwy3EW8onDT8hyOUMKht7DfUOAIJf3ApE68FR0desDjdof3jMxuJ8Z5FdUzJ o1RzI4vx9oWuMTTV/B+Wh9QND/xgMNI2+lhZdagUBuj2VTtuYGw39WUWc3l4se1fRmPl U7BJcZOPKieKaq7RhsrJtVYpc/XPlFL5DE10weFmjGaedXrjOBpGoXCwHnrMo/CbsFyR jXhQ== Original-Received: by 10.68.130.163 with SMTP id of3mr283088pbb.108.1347199941799; Sun, 09 Sep 2012 07:12:21 -0700 (PDT) Original-Received: from debian-6.05 ([115.242.215.162]) by mx.google.com with ESMTPS id nt7sm89166pbb.33.2012.09.09.07.12.17 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 07:12:20 -0700 (PDT) In-Reply-To: (Le Wang's message of "Sun, 9 Sep 2012 21:52:50 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.41 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86707 Archived-At: Le Wang writes: > On Sun, Sep 9, 2012 at 8:49 PM, Cecil Westerhof wrote: >> >> Thanks. That makes for better code. I now have the following code, >> that I am going to call from dcbl-gnus-get-mailing-list-address. Much >> more clear code and I have now a generic function that I can call from >> other places also. >> >> (defun dcbl-get-tuple-value (tuple index) >> "Get value from tuple indexed by index (if it exist);" >> (when index >> (catch 'loop >> (dolist (item tuple) >> (when (string-match (car item) index) >> (throw 'loop (cdr item))))))) > > > `dolist' (like all cl looping mechanisms) runs within an implicit anonymous > local return. So you can simply use > > (defun dcbl-get-tuple-value (tuple index) > "Get value from tuple indexed by index (if it exist);" > (when index > (dolist (item tuple) > (when (string-match (car item) index) > (return (cdr item)))))) > If you look at what the dolist does it is very similar to (assoc-default ) probably with an non-default test param. So a dolist is not even needed :-). > -- > Le > > --