This is a basic of functional programming and has my vote. 

Amos King
CEO
Binary Noggin

> On Jul 2, 2019, at 10:26, Chris Keathley <[email protected]> wrote:
> 
> I'm also in favor of including an `id` function.
> 
>> On Tue, Jul 2, 2019 at 8:52 AM Bruce Tate <[email protected]> wrote:
>> Strong +1 from me. 
>> 
>> I also think we need default functions for some Enum functions, such as 
>> filter. 
>> 
>> -bt
>> 
>>> On Tue, Jul 2, 2019 at 5:54 AM Wiebe-Marten Wijnja <[email protected]> wrote:
>>> I would usually be against introducing concepts to the core's standard 
>>> library that can be readily and easily expressed in user code.
>>> However, in this case I think there are two strong arguments for including 
>>> the identity function in the standard library:
>>> 
>>> 1. It is a great tool to help people new to functional programming with 
>>> their understanding.
>>> 2. It is a lot more clear in its purpose than `&(&1)` because it has a 
>>> name. (c.f. earlier operators vs named functions discussions).
>>> 
>>> ~Marten/Qqwy
>>> 
>>>> On Tuesday, July 2, 2019 at 11:23:47 AM UTC+2, Alexey Nikitin wrote:
>>>> Like Haskell's `id` or Clojure's `identity` or Ruby's `itself`
>>>> 
>>>> It can be very useful sometimes. Instead of writing ugly `&(&1)` it would 
>>>> much more attractive to write `&identity/1` or `&id\1`
>>>> Moreover this function is already used as a default argument for some 
>>>> higher-order function. For example `Enum.group_by(enumerable, key_fun, 
>>>> value_fun \\ fn x -> x end)`
>>>> 
>>>> Here are some examples
>>>> 
>>>> ```
>>>> #=> [1, 2, 3, true, 1234]
>>>> 
>>>> 'abcdaabccc' |> Enum.sort |> Enum.chunk_by(&identity/1)
>>>> #=> ['aaa', 'bb', 'cccc', 'd']
>>>> 
>>>> [1, 1, 2, 3, 3, 1, 1, 5, 5] |> Enum.chunk_by(&identity/1) |> 
>>>> Enum.map(&hd/1)
>>>> #=> [1, 2, 3, 1, 5]
>>>> 
>>>> Enum.group_by('abracadabra', &identity/1)
>>>> #=> %{97 => 'aaaaa', 98 => 'bb', 99 => 'c', 100 => 'd', 114 => 'rr'}
>>>> 
>>>> Enum.map([1, 2, 3, 4], &identity/1)
>>>> #=> [1, 2, 3, 4]
>>>> [1,2,3,nil, true, false, 1234] |> Enum.filter(&identity/1)
>>>> ```
>>> 
>>> -- 
>>> 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/b6b3359a-582b-4b42-88d3-10674c6227a5%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>> 
>> 
>> -- 
>> 
>> Regards,
>> Bruce Tate
>> CEO
>> 
>> 
>> 
>> Groxio, LLC.
>> 512.799.9366
>> [email protected]
>> grox.io
>> -- 
>> 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/CAFXvW-77OuMxqK1hPfzzjggM6fX9wTtGiS1Y9%3D7d%2BUiJQsJNXA%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> Chris
> -- 
> 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/CAGjNwxrsRgVVkHOT46wGZgGQ885ccONMyGmBjs3U4efdrJF0vA%40mail.gmail.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/664BB617-14EF-4B55-A076-696B811FF66D%40binarynoggin.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to