help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Break from a dolist


From: Jambunathan K
Subject: Re: Break from a dolist
Date: Sun, 09 Sep 2012 19:43:05 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Le Wang <l26wang@gmail.com> writes:

> On Sun, Sep 9, 2012 at 8:49 PM, Cecil Westerhof <Cecil@decebal.nl> 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
>
>

-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]