>
> 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)))
>

I really don't agree that `Enum.compact(list)` is somehow more revealing
than `Enum.reject(list, &is_nil/1)` - it is clear what the latter will do,
it is not clear what the former will do. I think there is a lot more of the
Ruby bias in this statement than you think ;). I'm not sold on the idea of
adding a function to the standard library which is so trivially written
with functions that already exist, at the sacrifice of clarity.

Paul

On Wed, May 17, 2017 at 10:14 AM, OvermindDL1 <[email protected]> wrote:

> 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
> <https://groups.google.com/d/msgid/elixir-lang-core/0bcae60f-2dca-466a-8d62-e03d75028eee%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAK%3D%2B-TsRAUXSmZ0_yOgZw22bf6zzvQHEZtp%3Dshq7QUyQ1cmK0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to