From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: How to flatten a one-level-deep list? Date: Wed, 18 May 2016 23:07:53 +0200 Message-ID: <86mvnnaxcm.fsf@student.uu.se> References: <877fes54pz.fsf@mbork.pl> <20160518082123.GB4640@tuxteam.de> <87lh37vh9q.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1463605723 16939 80.91.229.3 (18 May 2016 21:08:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 May 2016 21:08:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 18 23:08:35 2016 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 1b38hm-0000vA-T4 for geh-help-gnu-emacs@m.gmane.org; Wed, 18 May 2016 23:08:35 +0200 Original-Received: from localhost ([::1]:47090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b38hl-0000xR-Mr for geh-help-gnu-emacs@m.gmane.org; Wed, 18 May 2016 17:08:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b38hM-0000xE-06 for help-gnu-emacs@gnu.org; Wed, 18 May 2016 17:08:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b38hF-00016g-Qn for help-gnu-emacs@gnu.org; Wed, 18 May 2016 17:08:06 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:51557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b38hF-00016R-K1 for help-gnu-emacs@gnu.org; Wed, 18 May 2016 17:08:01 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b38hD-0000X6-HN for help-gnu-emacs@gnu.org; Wed, 18 May 2016 23:07:59 +0200 Original-Received: from c-9ce1e655.08-680-7570702.cust.bredbandsbolaget.se ([85.230.225.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 18 May 2016 23:07:59 +0200 Original-Received: from embe8573 by c-9ce1e655.08-680-7570702.cust.bredbandsbolaget.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 18 May 2016 23:07:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 27 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-9ce1e655.08-680-7570702.cust.bredbandsbolaget.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:47TQrUDMxWpn7mZ7B8p3rZTlIg8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:110060 Archived-At: Marcin Borkowski 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 -