Re: Enum.one?/1 and Enum.one?/2

117 views
Skip to first unread message
Message has been deleted

jisaa...@gmail.com

unread,
Oct 6, 2015, 4:48:28 PM10/6/15
to elixir-lang-core
My feelings:

> It is not solving a complex problem. Can be written in a single line

> It is not solving a common problem. I don't think I've ever had to write an equivalent function.

So personally I am against having it in stdlib.

On Monday, October 5, 2015 at 11:27:06 AM UTC-7, Bryan Enders wrote:
I believe `one?` would be a useful Enum function. It exists in Ruby's Enumerable module. It invokes a given function for each item in the enumerable and returns true if exactly one invocation returns a truthy value. It returns false otherwise.

This function tests for uniqueness or singularity. Unlike other uniqueness queries, it is concerned with the satisfaction of some criteria (expressed in the function argument) instead of an item's identity.

I have implemented `Enum.one?/1` and `Enum.one?/2` in this branch. A discussion began in a related pull request.

It is useful in Ruby. Do you think it has a place in Elixir?

Booker Bense

unread,
Oct 6, 2015, 5:00:42 PM10/6/15
to elixir-lang-core
I agree, however this does bring up an issue of utils that I think might be 
usefully used in Elixir. 

I should probably flesh this out in another message. 

- Booker C. Bense 

Aleksei Magusev

unread,
Oct 7, 2015, 3:22:04 PM10/7/15
to elixir-lang-core
Following on what has been said in the linked issue, I do think we should not have had `Enum.sum/1` at first place.

Booker Bense

unread,
Oct 13, 2015, 10:37:49 AM10/13/15
to elixir-lang-core
This would be a great addition to the Crutches project. 


- Booker C. Bense
Reply all
Reply to author
Forward
Message has been deleted
0 new messages