Seeing Enum.all?/2 being available made me assume there was also an Enum.none?/2 (like in Ruby), and I was a bit suprised to learn there was no such thing.
I'm aware that I could just do !Enum.all?/2, but Enum.none?/2 sees much nicer to me.
One more argument that I could make is that !Enum.all?/1 == Enum.none?/1 is not true in all cases.
Example:
If we have [false, true], !Enum.all?/1 will be true, but Enum.none?/1 will be false
I would like your thoughts on this one.
--
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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0b68e108-825f-49d5-86ec-317caa2a852fn%40googlegroups.com.
--
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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0b68e108-825f-49d5-86ec-317caa2a852fn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/187f642b-209b-4f99-867d-a3c173962b1cn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3c24688c-5877-47f0-87c0-e7428345a15en%40googlegroups.com.
I’ll add my support for an explicit `Enum.none?/2`, even though `!Enum.any?(llst)` or `Enum.any?(list, & !&1)` is equivalent. I haven’t faced this particular problem *in Elixir*, but JavaScript doesn’t have this, and I make the mistake of using `!list.all()` instead of `!list.some()` *every single time* I have to implement it.It’s a subtle enough difference that I think that the increased readability and reduced error rate are worth the added API space, as simply documenting this particular use case in `Enum.any?/2` would end up begging the question as to why not implement this as a standard function, and leaving it undocumented leads to incorrect implementations.-a
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3c24688c-5877-47f0-87c0-e7428345a15en%40googlegroups.com.
--
--
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 elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQtQnsop1Rb4OAL_eF%2BRMHgJR6dXhaxaW0V_URMUw12BRg%40mail.gmail.com.
I think there is a really important function of a standard library for things like this. This conversation has effectively generated knowledge, specifically that the best way to implement `Enum.none?/2` is simply by negating `Enum.any?/2`. And while it is very easy for anyone to add this code to their project `!Enum.any?/2` what is *not* so easy is knowing that "the best way to implement `Enum.none?/2` is via negating `Enum.any?/2`. We all have that context now, so it is easy to say it shouldn't be in the standard library. I don't think that things only belong in the std library if the std library offers an optimization. Sometimes the important context is that the std library *doesn't* offer an optimization. Personally, I believe things like `Enum.none?/2` belong in the std library.
On Wed, Jun 22, 2022 at 10:49 AM, Austin Ziegler <halos...@gmail.com> wrote:
I’ll add my support for an explicit `Enum.none?/2`, even though `!Enum.any?(llst)` or `Enum.any?(list, & !&1)` is equivalent. I haven’t faced this particular problem *in Elixir*, but JavaScript doesn’t have this, and I make the mistake of using `!list.all()` instead of `!list.some()` *every single time* I have to implement it.It’s a subtle enough difference that I think that the increased readability and reduced error rate are worth the added API space, as simply documenting this particular use case in `Enum.any?/2` would end up begging the question as to why not implement this as a standard function, and leaving it undocumented leads to incorrect implementations.-a
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3c24688c-5877-47f0-87c0-e7428345a15en%40googlegroups.com.
--Austin Ziegler • halos...@gmail.com • aus...@halostatue.ca
http://www.halostatue.ca/ • http://twitter.com/halostatue
--
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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQtQnsop1Rb4OAL_eF%2BRMHgJR6dXhaxaW0V_URMUw12BRg%40mail.gmail.com.
--
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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/l4pq6nw3.cbf23422-0630-4845-acdc-9c7dde6281e8%40we.are.superhuman.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/c7972043-e787-4f83-a9e3-8fc67541103cn%40googlegroups.com.