You want to add a default of 1 to Enum.take/2? I personally don't mind that but 
I think it takes away from the explicit nature of the module. I prefer 
explicitness if we are only saving a few keystrokes. 

Amos King
Binary Noggin

> On Apr 22, 2017, at 04:12, Sam Davies <[email protected]> wrote:
> 
> I understand the reasoning. That's why I suggest the name `take` NOT the name 
> `first` to make it clear there is no implied ordering.
> 
> The use case for this is often while working in IEx. I have a collection of 
> _somethings_ and I want to see what one _something_looks like. I don't care 
> about ordering.
> 
> Rails' ActiveRecord has a method called `take` which does much the same thing 
> - there is no implied ordering, it just grabs a member using some unspecified 
> ordering and returns it.
> 
> We already have `take/1` which returns the "first" X elements, so it seems 
> logical to me to extend that to `take/0` which returns the "first" ONE 
> element.
> 
>> On Thursday, April 20, 2017 at 5:55:22 PM UTC+1, Allen Madsen wrote:
>> Also hd, which takes the head of the list.
>> 
>> Allen Madsen
>> http://www.allenmadsen.com
>> 
>>> On Thu, Apr 20, 2017 at 12:44 PM, OvermindDL1 <[email protected]> wrote:
>>> Two things:
>>> 1. The `List` module already has a `List.first/1`.
>>> 2. Not all enumerables have a concept of ordering, like a map, so I'm not 
>>> sure an Enum version of such a thing makes conceptual sense?
>>> 
>>>> On Thursday, April 20, 2017 at 10:33:11 AM UTC-6, Sam Davies wrote:
>>>> When working with collections it's often convenient to grab the first 
>>>> element that comes to hand. I find myself writing this a lot:
>>>> 
>>>> `Enum.take(collection, 1)` or `Enum.at(collection, 0)`
>>>> 
>>>> How about a function `Enum.take/1` which takes only the collection and 
>>>> returns the "first" value (I avoid naming it `Enum.first/1` since some 
>>>> collections may not have any concept of ordering).
>>> 
>>> -- 
>>> 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/69a0953e-07b3-4cc6-8cc0-bee718337ea5%40googlegroups.com.
>>> 
>>> 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/bd395d6b-e64d-41ef-970e-8ac33c0e279c%40googlegroups.com.
> 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/DE712080-F4D8-41CD-90A1-B5BC2D045023%40binarynoggin.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to