all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Exiting from mapc
Date: Thu, 2 Jan 2025 13:53:54 +0300	[thread overview]
Message-ID: <Z3ZwQrnkynsz_3At@lco2> (raw)
In-Reply-To: <7cSjmNb9wbuuXOPxnBml1e6cPaldn8EPTGZ2LZdnm-ZjIANwQBYOYq9a-nJDcaCG8QKkb09TGeUjlQ6vLFyFVzOPZfJniDINxCNXT1TW6vQ=@protonmail.com>

* Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2024-12-31 22:37]:
> 
> How can I exit when encountering 'safg or 'nogo 
> 
> (defun amazones-falkotr-kntlr (actm-seqr)
> 
>   (mapc
> 
>     (lambda (actm)
>       ;; Evaluate conditions and executes corresponding actions
>       ;; based on matching clauses.
> 
>       (cond
> 
>         ;; CASE
>         ((eq actm 'safg)
>            (message "SAFG amazones-falkotr-kntlr"))

To answer the message "How can I exit when encountering 'safg or
'nogo', yes, you can exit.

Here is what happens if there is no number 1 in the list here below:

(let ((list (catch 'no-go
  (mapc (lambda (item)
          (if (= item 1)
              (throw 'no-go nil)
            (message "Processing item: %S" item)))
        '(2 3 4 5 6)))))
list)  ➜ (2 3 4 5 6)

But if there is number one, `throw' exits:

(let ((list (catch 'no-go
  (mapc (lambda (item)
          (if (= item 1)
              (throw 'no-go nil)
            (message "Processing item: %S" item)))
        '(2 1 3 4 5 6)))))
list)
Processing item: 2
and finished there!

So yes, you can exit from mapc if you enclose it with `catch' this way.

-- 
Jean Louis



  parent reply	other threads:[~2025-01-02 10:53 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-31 19:35 Exiting from mapc Heime via Users list for the GNU Emacs text editor
2024-12-31 20:13 ` [External] : " Drew Adams
2024-12-31 20:20   ` Heime via Users list for the GNU Emacs text editor
2024-12-31 22:30     ` Drew Adams
2025-01-01 23:14       ` Heime via Users list for the GNU Emacs text editor
2025-01-02  0:31         ` Joel Reicher
2025-01-02 10:33           ` Jean Louis
2025-01-03  0:23             ` Joel Reicher
2025-01-03  7:49               ` Jean Louis
2025-01-03 12:59                 ` Van Ly via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2025-01-03 14:55                   ` Jean Louis
2025-01-11  8:19                     ` Joel Reicher
2025-01-11 10:35                       ` Van Ly via Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists
2025-01-11 12:19                       ` Eduardo Ochs
2025-01-11  8:17                   ` Joel Reicher
2025-01-11  8:14                 ` Joel Reicher
2025-01-11  9:14                   ` was - " Jean Louis
2025-01-11 13:42                     ` Joel Reicher
2025-01-11 14:02                       ` Jean Louis
2025-01-11 14:15                         ` Joel Reicher
2025-01-11 14:37                           ` Jean Louis
2025-01-12  8:46                             ` Joel Reicher
2025-01-12  9:24                               ` Jean Louis
2025-01-02  0:33         ` [External] : " Drew Adams
2025-01-02  2:21         ` Eduardo Ochs
2025-01-01  1:53   ` Björn Bidar
     [not found]   ` <87wmffwb8w.fsf@>
2025-01-01  2:02     ` Drew Adams
2025-01-01 19:40       ` Björn Bidar
     [not found]       ` <874j2iwcff.fsf@>
2025-01-01 20:00         ` Drew Adams
2025-01-01 21:09           ` Björn Bidar
     [not found]           ` <87a5cautqb.fsf@>
2025-01-01 21:59             ` Drew Adams
2025-01-02 10:53 ` Jean Louis [this message]
2025-01-11 14:48   ` Did you finally exit from mapc? Jean Louis
2025-01-11 16:55     ` Heime via Users list for the GNU Emacs text editor
2025-01-11 18:50       ` [External] : " Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z3ZwQrnkynsz_3At@lco2 \
    --to=bugs@gnu.support \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.