If you use an erlang nil `[]` (the empty list) instead of a Elixir's `nil` (which is an atom, which is weird) as nil's then you can just use `:lists.flatten`.
On Wednesday, May 17, 2017 at 4:28:30 AM UTC-6, Sam Davies wrote: > > +1 for this > > On Wednesday, August 28, 2013 at 5:49:33 PM UTC+1, Steve Downey wrote: >> >> This is probably my Ruby experience/bias exposing itself but: >> >> - removing nil elements from a collection is a common pattern >> - Enum.compact(list) is more intention-revealing than Enum.reject(list, >> &(nil?(&1))) >> >> >> On Monday, August 26, 2013 3:40:33 PM UTC-7, Patrick Van Stee wrote: >>> >>> Would implementing an `Enum.compact/1` be useful to anyone? It would >>> basically just be the same as calling `Enum.reject` with `&nil?/1`. >>> >>> Here's an example: >>> >>> iex> Enum.compact([1, nil, 3, nil, 5]) >>> [1, 3, 5] >>> >> -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0bcae60f-2dca-466a-8d62-e03d75028eee%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
