From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: How to flatten a one-level-deep list?
Date: Wed, 18 May 2016 23:07:53 +0200 [thread overview]
Message-ID: <86mvnnaxcm.fsf@student.uu.se> (raw)
In-Reply-To: 87lh37vh9q.fsf@mbork.pl
Marcin Borkowski <mbork@mbork.pl> writes:
>> (setq l '((a b c) (d e f) (g h i))) (apply 'append l) => (a b c d e f g h i)
>> No idea whether performance or edge cases match your requirements, though :)
>
> Thanks, that looks fine. Meanwhile, I went
> with a mapconcat nested within a mapconcat
> (the atoms I have are strings, and what
> I really need is concatenation of all of
> them).
C-h a flatten RET anyone?
(defun message-flatten-list (list)
"Return a new, flat list that contains all elements of LIST.
\(message-flatten-list '(1 (2 3 (4 5 (6))) 7))
=> (1 2 3 4 5 6 7)"
(cond ((consp list)
(apply 'append (mapcar 'message-flatten-list list)))
(list
(list list))))
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 33 Blogomatic articles -
next prev parent reply other threads:[~2016-05-18 21:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-18 5:12 How to flatten a one-level-deep list? Marcin Borkowski
2016-05-18 8:21 ` tomas
2016-05-18 9:37 ` Marcin Borkowski
2016-05-18 21:07 ` Emanuel Berg [this message]
2016-05-20 12:17 ` Stefan Monnier
2016-05-20 15:01 ` Michael Heerdegen
2016-05-20 17:20 ` Marcin Borkowski
2016-05-20 17:54 ` Michael Heerdegen
2016-05-20 19:51 ` Marcin Borkowski
2016-05-20 22:14 ` Michael Heerdegen
[not found] ` <mailman.46.1463559697.6543.help-gnu-emacs@gnu.org>
2016-05-18 17:52 ` Pascal J. Bourguignon
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=86mvnnaxcm.fsf@student.uu.se \
--to=embe8573@student.uu.se \
--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.