#=> [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,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 elixir-lang-co...@googlegroups.com.
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.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGjNwxrsRgVVkHOT46wGZgGQ885ccONMyGmBjs3U4efdrJF0vA%40mail.gmail.com.
bar = &foo/0 bar.() #=> 1 bar() #=> 2 def foo(), do: 1 def bar(), do: 2
Having a Kernel.id/1 function would not preclude you from using variables called id.
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fffd5b76-4385-40de-93bd-148f1b94bb27%40googlegroups.com.
Like Haskell's `id` or Clojure's `identity` or Ruby's `itself`
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/tB61BHYIH1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b2149582-b8ba-4759-99ac-a634f73f3243%40Spark.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAD9kT2R41gmZXU9_YAqAdyJQDP-M37j-mgUet-okoeBzF%3DdMDA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fffd5b76-4385-40de-93bd-148f1b94bb27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/tB61BHYIH1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b2149582-b8ba-4759-99ac-a634f73f3243%40Spark.
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 elixir-l...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/458469ec-ac00-4155-b8f0-717e6623f820%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAKBKqKQRVE1wPbfqPVSsuiR7oBUiRTAKLqojmUtZ6-G94VohPg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3CtUqEy84xBwaU942exgh0y0JKq3F9XQ__BcJRyMo0Q2Qw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-7%3DfZ2r0a8Urxvg%2B5yHee0gmXZ%3DVVMTuNo05gSOgwkf%2Bg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fffd5b76-4385-40de-93bd-148f1b94bb27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/tB61BHYIH1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b2149582-b8ba-4759-99ac-a634f73f3243%40Spark.
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 elixir-l...@googlegroups.com.
+1
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/c42c687b-681f-4863-9628-6819affd8738%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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/95820767-2333-4A24-BDD0-BB4838DCF32D%40gmail.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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/ea64c4f1-27e0-46e8-9e2a-c0cebc8a2728%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/52d2c2bc-f15c-48c0-b904-673cad6af06a%40www.fastmail.com.
Thanks Chris, it is important that someone being counter arguments, even if they can be disproved. :)
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fffd5b76-4385-40de-93bd-148f1b94bb27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/tB61BHYIH1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b2149582-b8ba-4759-99ac-a634f73f3243%40Spark.
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 elixir-l...@googlegroups.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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2e98526b-e83c-4b92-8035-26bce95da822%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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2e98526b-e83c-4b92-8035-26bce95da822%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-5vOv15iAWWH6qvbyUPf7KrY2Smw0oBKdf56%3DLPiH9BNA%40mail.gmail.com.
It mainly consists of:
- basic language primitives, such as arithmetic operators, spawning of processes, data type handling, etc.
- macros for control-flow and defining new functionality (modules, functions, and so on)
- guard checks for augmenting pattern matching
Generally speaking, I agree with Chulki Lee.I understand the value of the identity function. But the cons of adding it to Kernel is that we partially take the name away from everyone else, unless they unimport it, and ultimately the implementation of identity/1 is not doing much to wararnt this loss.José ValimSkype: jv.ptecFounder and Director of R&D
On Fri, Jul 12, 2019 at 6:59 PM Chulki Lee <chul...@gmail.com> wrote:
--I'm happy to see Elixir adopting FP concept here ([identity function](https://en.wikipedia.org/wiki/Identity_function)), but I'm not sure it's good to add it to `Kernel` (as it's imported by default!) - or even in Elixir core.Why should we add this to Elixir core, instead of "extending" with module?```elixirdefmodule FP dodef identity(a), do: aenddef module YourApp doimport FPdef hello do'abcdaabccc' |> Enum.sort |> Enum.chunk_by(&identity/1)endend```For example, that library can be de-facto helper for such FP utility functions.
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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LX2L155aA6koxFGFmKdBoNoaRYmX83BQMFBnQRw-fLhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-6xhMw0UbpO7hL0Lm7bOp1Q%3D2EG6axNcH530BDN_U6i5A%40mail.gmail.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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/C4BDFC3F-1646-4957-B814-0204D3B147A6%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFuVuxzkdQbPZaPHRWA6w13LE1jFZm-sgoxK8ToOkTag2_9AbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
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 because the definition of Identity they use when talking about values and change is a more complex one (and one that really stuck with me):> By identity I mean a stable logical entity associated with a series of different values over timeOf course, my interpretation above is likely uncommon and there are other interpretations of identity that would fit nicely.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.Thank you,
José ValimSkype: jv.ptecFounder and Director of R&D
--
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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fffd5b76-4385-40de-93bd-148f1b94bb27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/tB61BHYIH1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b2149582-b8ba-4759-99ac-a634f73f3243%40Spark.
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 elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAD9kT2R41gmZXU9_YAqAdyJQDP-M37j-mgUet-okoeBzF%3DdMDA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2bb429a8-e583-48c1-a335-8660c115b24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I understand that the desire from the core team isn't to add this. I'm OK with that decision despite feeling like it would be a good addition That's fine.But I do take issue with this "slippery slope" argument that adding `identity` to Elixir would somehow open the door to numerous other functions being added to Elixir. Which is silly. Because we aren't talking about adding some untold number of functions to Elixir. We're talking about `identity`. If the core team had decided that `identity` was worth having in the language would we still not add it because later someone could add the `snausages` function? No. Of course not. That's a nonsensical argument. Improvements to the language should be considered on their own terms.
On Sat, Jul 13, 2019 at 12:26 AM Sven Gehring <cbr...@gmail.com> wrote:
I definitely agree that it's better to import it from an additional module if need be.If we ignore the Metaprogramming parts, Elixir has a very easy Syntax and the &(&1) notation is one of the only non-intuitive things to learn. Compared to other languages, there are virtually no 'weird' syntax elements you have to 'just remember' when you start out, so I am actually in favor of teaching people this shorthand instead of hiding it from them. (It's really not THAT complicated)Also, as José said, you can always use "fn x -> x end", which is about the same length as "&identity/1" and also obvious in what it does.I don't think expanding the Kernel just for the sake of adopting concepts of similar ecosystems is worth it.Sven
On Fri, Jul 12, 2019, 23:10 Rich Morin <r.d...@gmail.com> wrote:
> On Jul 12, 2019, at 13:43, José Valim <jose...@plataformatec.com.br> wrote:
>
> Filtering nils may be considered bad practice (i.e. why do you have nils there?)
I use them, on occasion, to support a "maybe" type.
> ... it may be more readable to do with Enum.reject(&is_nil/1).
Cool! I just replaced four instances of `Enum.filter(&(&1))` with `Enum.reject(&is_nil/1)`.
FWIW, I'd love to see an annotated collection of suggested Elixir idioms such as this one.
-r
--
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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/C4BDFC3F-1646-4957-B814-0204D3B147A6%40gmail.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 elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFuVuxzkdQbPZaPHRWA6w13LE1jFZm-sgoxK8ToOkTag2_9AbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--Chris
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/aa6ad3d9-abc6-4afb-b153-26491d3cc6b4%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BJEN7vuwxxZFkrB8NytCCaSPAKtroMeA1sqe91n5SoFXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-65ztTOMoVhZ407PghmYA0OBcuVhDatcjYx6Xw7f52pMQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/702CFF39-BCFF-416F-BF28-81A5E1516903%40chrismccord.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2bb429a8-e583-48c1-a335-8660c115b24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Andrea Leopardi--
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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BJEN7vuwxxZFkrB8NytCCaSPAKtroMeA1sqe91n5SoFXg%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 elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-65ztTOMoVhZ407PghmYA0OBcuVhDatcjYx6Xw7f52pMQ%40mail.gmail.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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/702CFF39-BCFF-416F-BF28-81A5E1516903%40chrismccord.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/586eb969-e70d-44cb-98df-47b8f6c188d0%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/586eb969-e70d-44cb-98df-47b8f6c188d0%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-co...@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.
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.
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/91e7fbd2-b138-4db7-9b8f-530053fd936e%40googlegroups.com.
https://groups.google.com/forum/m/#!search/tallak$20unity/elixir-lang-core/Q2eO8dRqrmA
Happy about this too!