From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Surprising behaviour of 'append' with strings
Date: Sun, 06 Nov 2022 21:33:38 +0100 [thread overview]
Message-ID: <87y1snbz6l.fsf@web.de> (raw)
In-Reply-To: 6554cc02-2082-3dca-73cc-05fee1c6c4d0@yahoo.de
"R. Diez" <rdiezmail-emacs@yahoo.de> writes:
> I need a routine like this:
>
> (my-append
> "1"
> (list "2" "3")
> "4"
> )
>
> The result should be:
> ("1" "2" "3" "4")
(defun my-append (&rest args)
(cl-mapcan (lambda (x) (if (consp x) x (list x)))
args))
> As a bonus, 'my-append' should check that all elements are strings, or
> list of strings (no nested lists, and no other data types).
Use `cl-every' on the result of `my-append' with a `stringp' predicate.
Michael.
next prev parent reply other threads:[~2022-11-06 20:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6554cc02-2082-3dca-73cc-05fee1c6c4d0.ref@yahoo.de>
2022-11-06 11:05 ` Surprising behaviour of 'append' with strings R. Diez
2022-11-06 12:13 ` Stephen Berman
2022-11-06 12:35 ` Emanuel Berg
2022-11-06 20:28 ` Michael Heerdegen
2022-11-06 20:57 ` Emanuel Berg
2022-11-06 12:19 ` Emanuel Berg
2022-11-06 12:32 ` Emanuel Berg
2022-11-06 12:37 ` Eli Zaretskii
2022-11-06 12:39 ` Jean Louis
2022-11-06 20:33 ` Michael Heerdegen [this message]
2022-11-06 21:45 ` [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=87y1snbz6l.fsf@web.de \
--to=michael_heerdegen@web.de \
--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.