I thought about said approach but returning anonymous functions are not very common in Elixir (probably due to the lack of currying) and also less efficient. So I would prefer Function.identity/1.
*José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Wed, Jul 31, 2019 at 7:41 PM Devon Estes <devon.c.es...@gmail.com> wrote: > What about Function.identity/0, that returns an anonymous identify > function? > > def identity(), do: &(&1) > > So usage would look like: > > Enum.map(list, Function.identity()) > > That (to me) works just as well as Function.identity/1, and keeps with the > convention of functions in the Function module returning functions. > > It is an additional layer of indirection, but I honestly don’t think this > is going to be a feature that’s used by anyone other than advanced users. > It might be confusing to those new to FP, but those folks won’t even think > to use this feature, at least not by name. > > -- > 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 visit > https://groups.google.com/d/msgid/elixir-lang-core/ff409509-d00f-4b09-b03f-c2f16217c091%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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K%2BPrJMtc34sYwrsgQ4NLJ%3DxLY%3Dy5axHy1%2BFTwZYSjGxg%40mail.gmail.com.