emacs-devel
[Top][All Lists]
Advanced

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

Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]


From: Stefan Monnier
Subject: Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]
Date: Sun, 10 May 2020 15:31:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> there I think I just want flatten to exist already.

His point was: it's rare to need exactly `flatten` (which BTW is called
`flatten-tree` since Emacs-27 ;-).
AFAIK in most cases what you really want is something along the lines of
(apply #'append X), i.e. a "one-level flatten".

As its name implies, `flatten-tree` really operates on a tree, but it's
very rare to represent trees in Elisp in such a way that all non-cons
cells are elements of the tree, so `flatten-tree` rarely does something
meaningful on a tree.

But yes, there are several cases where you may happen to know that
`flatten-tree` will work because it won't have the opportunity to go
deeper than the first level.  I.e. you have a "list of lists of strings"
or a "list of either strings or lists of strings", so you won't see the
difference between `flatten-tree` and a hypothetical one-level flatten.


        Stefan




reply via email to

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