[elixir-core:8910] Re: [Proposal] identity function

2019-07-02 Thread Виталий Миляков
> > +1 > Great Idea! -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visi

Re: [elixir-core:8909] Re: [Proposal] identity function

2019-07-02 Thread Alexey Nikitin
The name may be not the best. It has mathematical roots. But everyone is used to it. It's like "lambda" :) Who could ever imagine that the greek letter is an anonymous function. But as well as "identity" is the most understandable and familiar name for fp-fans. People look for it by intuition h

[elixir-core:8908] Re: [Proposal] identity function

2019-07-02 Thread Tyson Buzza
In my post before, the code example I gave should have been `& {&1.id, &1 .name }` On Tuesday, July 2, 2019 at 5:23:47 PM UTC+8, 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 `&(

[elixir-core:8907] Re: [Proposal] identity function

2019-07-02 Thread Tyson Buzza
The existing way of doing this might allow beginners to develop a better intuition for the Elixir's capture operator. For example consider this code for creating a lookup map from a list of maps: ``` lookup = Enum.map(map_list, & {&1.id, &2.name}) |> Enum.into(%{}) ``` Knowing about `& &1` all

Re: [elixir-core:8905] [Notions] extend function capture syntax

2019-07-02 Thread Rich Morin
Thanks for all the thoughtful responses. Also, apologies for the ambiguities and omissions in my original note. As so often happens, some of the things I had in mind didn't make it into my email. (sigh) In this note, I'm only considering the case of named functions that are explicitly handed

Re: [elixir-core:8904] Re: [Proposal] identity function

2019-07-02 Thread Rich Morin
> On Jul 2, 2019, at 14:11, Greg Vaughn wrote: > > Can we have some fun with this? Maybe use the unicode "identical to" symbol? ≡ > :-) (only half-joking) It's great that Elixir supports Unicode (how else could we spell José?), but I really hope that using Unicode doesn't become any sort of requ

[elixir-core:8904] Re: [Notions] extend function capture syntax

2019-07-02 Thread Roman Smirnov
Seems you would like to have currying in Elixir. It's not possible in general way on BEAM, but I had fun with doing it some years ago: https://github.com/romul/utils/blob/master/lib/utils/functions.ex#L49 So, you could use it like Enum.map(rcarry(&Tuple.append/2, 42)) вторник, 2 июля 2019 г., 19

Re: [elixir-core:8902] Re: [Proposal] identity function

2019-07-02 Thread Greg Vaughn
Can we have some fun with this? Maybe use the unicode "identical to" symbol? ≡ :-) (only half-joking) -Greg Vaughn > On Jul 2, 2019, at 4:02 PM, Bruce Tate wrote: > > I could learn to like &id/1, and also think that &ident/1 fits Elixir's style > of abbreviation. My vote is for either one of t

Re: [elixir-core:8901] Re: [Proposal] identity function

2019-07-02 Thread Parker Selbert
I’m in favor of the addition overall. The specific function name matters less to me, &identity/1 or &id/1 would be fine. > On Jul 2, 2019, at 16:02, Bruce Tate wrote: > > I could learn to like &id/1, and also think that &ident/1 fits Elixir's style > of abbreviation. My vote is for either one

Re: [elixir-core:8900] Re: [Proposal] identity function

2019-07-02 Thread Bruce Tate
I could learn to like &id/1, and also think that &ident/1 fits Elixir's style of abbreviation. My vote is for either one of those. -bt On Tue, Jul 2, 2019 at 4:47 PM Allen Madsen wrote: > And identity in mathematics: > https://en.wikipedia.org/wiki/Identity_function > > Allen Madsen > http://ww

Re: [elixir-core:8899] Re: [Proposal] identity function

2019-07-02 Thread Allen Madsen
And identity in mathematics: https://en.wikipedia.org/wiki/Identity_function Allen Madsen http://www.allenmadsen.com On Tue, Jul 2, 2019 at 4:05 PM Ryan Winchester wrote: > And `identity` in Scala > > docs: > https://www.scala-lang.org/api/current/scala/Predef$.html#identity[A](x:A):A > > > in

Re: [elixir-core:8898] Re: [Proposal] identity function

2019-07-02 Thread Ryan Winchester
And `identity` in Scala docs: https://www.scala-lang.org/api/current/scala/Predef$.html#identity[A](x:A):A interesting read: https://emilvarga.com/posts/2016/08/01/using-identity-functions On July 2, 2019 at 1:00:53 PM, Wiebe-Marten Wijnja (w...@resilia.nl) wrote: > Anyway, to move the discus

Re: [elixir-core:8898] Re: [Proposal] identity function

2019-07-02 Thread Wiebe-Marten Wijnja
> Anyway, to move the discussion forward, can someone do a more complete survey on what this function are called in many of the other languages? I just want to make sure we do our due diligence before adding it to the language. Haskell: id

Re: [elixir-core:8896] Re: [Proposal] identity function

2019-07-02 Thread José Valim
Thanks Chris, it is important that someone being counter arguments, even if they can be disproved. :) I definitely see how such a small function can be useful but, at the same time, I am not convinced about the name "identity". I found it curious that Clojure actually have an identity function be

Re: [elixir-core:8895] Re: [Proposal] identity function

2019-07-02 Thread Christopher Keele
Derp, I knew that. Good point. On Tue, Jul 2, 2019 at 9:55 AM Michał Muskała wrote: > Because Elixir is a lisp-2 language, variables and functions are in > different "namespaces". This means you can have local variables with names > of local functions without any issues, but it also means you ne

[elixir-core:8895] Re: [Proposal] identity function

2019-07-02 Thread Vadim Safonov
+1 would be very convenient вторник, 2 июля 2019 г., 12:23:47 UTC+3 пользователь Alexey Nikitin написал: > > 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` o

Re: [elixir-core:8893] [Notions] extend function capture syntax

2019-07-02 Thread José Valim
> When a captured function is being used as an argument, it may be possible > to infer its arity. So, maybe we can leave this out: > Enum.sort_by(&String.downcase) How would Elixir know if you meant downcase/1 or downcase/2 on functions like Enum.group_by which accept multiple arities? We would e

[elixir-core:8893] Re: [Proposal] identity function

2019-07-02 Thread Alexey Nikitin
>1. It'd suck to not be able to use 'id' as a variable name, and would conflict with a lot of existing code. Michał Muskała gave brilliant and comprehensive answer > 2. Alternative names to 'id' or namespacing it are not shorter than '&(&1)' length is not the main point. But semantics

Re: [elixir-core:8891] [Notions] extend function capture syntax

2019-07-02 Thread Louis Pilfold
Hiya Given Elixir has very limited ability to infer information at compile time how will the compiler know which function to capture? It is not possible to create a multiple-arity anonymous function on the BEAM. Cheers, Louis On Tue, 2 Jul 2019, 17:52 Rich Morin, wrote: > I enjoyed reading "[

Re: [elixir-core:8890] Re: [Proposal] identity function

2019-07-02 Thread Michał Muskała
Because Elixir is a lisp-2 language, variables and functions are in different "namespaces". This means you can have local variables with names of local functions without any issues, but it also means you need different syntax when you want to call a function contained in a variable. Or formulate

[elixir-core:8889] [Notions] extend function capture syntax

2019-07-02 Thread Rich Morin
I enjoyed reading "[elixir-core:8881] [Proposal] identity function" and the ensuing discussion. It strikes me that some simple extensions to Elixir's function capture syntax might: - clean up the appearance of function captures - make existing functions more generally useful - reduce the need for

[elixir-core:8889] Re: [Proposal] identity function

2019-07-02 Thread Christopher Keele
I'd cast my vote against this. The proposal seems to be: 1. Create a function named 'id' or some such 2. Put it in the Kernel namespace (so it need not be prefixed) I've been doing a lot of python lately and they have a lot of things like this, including the same 'filter' global function mention

Re: [elixir-core:8887] Re: [Proposal] identity function

2019-07-02 Thread Amos King
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 wrote: > > I'm also in favor of including an `id` function. > >> On Tue, Jul 2, 2019 at 8:52 AM Bruce Tate wrote: >> Strong +1 from me. >> >> I also think we ne

Re: [elixir-core:8886] Re: [Proposal] identity function

2019-07-02 Thread Chris Keathley
I'm also in favor of including an `id` function. On Tue, Jul 2, 2019 at 8:52 AM Bruce Tate 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 wrote: > >> I would usually

Re: [elixir-core:8885] [Proposal] Module.attribute_registered?/3 or Add Module.has_attribute?/3

2019-07-02 Thread José Valim
It can’t be undone today either. This was just a general note. It probably belongs to a separate PR. -- *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To un

Re: [elixir-core:8884] Re: [Proposal] identity function

2019-07-02 Thread Bruce Tate
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 wrote: > I would usually be against introducing concepts to the core's standard > library that can be readily and easily expressed in user c

Re: [elixir-core:8883] [Proposal] Module.attribute_registered?/3 or Add Module.has_attribute?/3

2019-07-02 Thread Allen Madsen
> We need to document that once an attribute has been registered to accumulate or persist, it can't be done undone unless the attribute is deleted. How is it undone today? Allen Madsen http://www.allenmadsen.com On Tue, Jul 2, 2019 at 1:24 AM José Valim wrote: > Thanks for the proposal. > > I

[elixir-core:8883] Re: [Proposal] identity function

2019-07-02 Thread Wiebe-Marten Wijnja
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

[elixir-core:8882] Re: [Proposal] identity function

2019-07-02 Thread Роман Смирнов
+1 Could be very handy sometimes. вторник, 2 июля 2019 г., 12:23:47 UTC+3 пользователь Alexey Nikitin написал: > > 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 `&identit

[elixir-core:8881] [Proposal] identity function

2019-07-02 Thread Alexey Nikitin
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