Hi! Thank you for a great programing language.
This is a suggestion for a new enum function.
Add tally function like Rubys tally.
tally is Rubys 2.7.0 new function
https://bugs.ruby-lang.org/issues/11076
https://github.com/elixir-lang/elixir/pull/9373
iex> Enum.tally(~w{ant buffalo ant ant buffalo dingo})
%{"ant" => 3, "buffalo" => 2, "dingo" => 1}
iex> Enum.tally(~w{aa aA bb cc}, fn x -> String.downcase(x) end)
%{"aa" => 2, "bb" => 1, "cc" => 1}
The following article is more about this.
https://medium.com/@baweaver/ruby-2-7-enumerable-tally-a706a5fb11ea
Ruby 2.7.0 has not released yet but this function is really good
As I mentioned on the linked PR, I’m in favor of such feature. I like how Clojure calls this function: frequencies. Thus if we are considering Enum.frequencies/1 and/or Enum.frequencies/2, it has my vote.
To move the proposal forward I think it would be very valuable if you could survey other programming languages to see if they have such feature and if so - under what function 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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1ACBE99E-BE36-4035-991C-9BD03651048C%40wojtekmach.pl.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAL%3D_u%3DLVpD4Gf5Ay_ezX7W%3DFRoB5y31EU%3DLAiOHhTK%2BGSFyzeg%40mail.gmail.com.
I think the problem with including this in the core library is that you can end up with very different implementations depending on what your use case is. So, if it were included in the standard library, it would need to be explicit about when to use it and when not to.The version provided in the PR is memory inefficient, because it first does a group by, which requires it to retain every element in the collection. For simple, use cases that may be fine, but if you're streaming a large amount of data, you probably only want to keep track of the counts. If you're keeping track of the counts, you're probably being inefficient speed wise, because you're constantly updating the accumulator map for each item in the collection. To do that efficiently, you probably want to use an ETS table. But, do you really want an ETS table to be created any time you call this function?
On Mon, Sep 30, 2019 at 1:20 PM Paul Byrne <paulgreg...@gmail.com> wrote:
Most occasions I've needed to do this kind of count, I've been trying to get some data through the production console, rather than it being some business logic, to get a sense of how often some data problem has occurred.Given that I think it's a rather nice addition to the toolbox. It's certainly generic enough, though possibly too niche.Paul
On Mon, Sep 30, 2019, 12:57 Wojtek Mach <woj...@wojtekmach.pl> wrote:
As I mentioned on the linked PR, I’m in favor of such feature. I like how Clojure calls this function: frequencies. Thus if we are considering Enum.frequencies/1 and/or Enum.frequencies/2, it has my vote.
To move the proposal forward I think it would be very valuable if you could survey other programming languages to see if they have such feature and if so - under what function 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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1ACBE99E-BE36-4035-991C-9BD03651048C%40wojtekmach.pl.
--
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.
Hi! Thank you for a great programing language.
frequency sounds good!I also have tried to get some data through the production console.
PHP has a similar methodMay I update My PR?
2019年10月1日火曜日 7時36分56秒 UTC+9 OvermindDL1:
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/0e4dc6bc-4654-4698-b8a9-cc9b0782bbbc%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/CAGnRm4KqUJKyuD0CSe5gTHL761SR6CncKDD1ryTsHTuRWXFN8g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-5c86psRL5rf_vVtRiy_e5fDGc1%2BicM%2BZ3Z%2BD-%2BxhyS9A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/A87FBBAC-8F1E-450D-B844-A02F2F7A71B6%40gmail.com.
Enum.group_count/2 would be a name that describe better what this function does IMO, but it
wouldn't work as Enum.group_by/3 since this one groups by key, and group_count would group by
elements ({key, value})
On Sun, 6 Oct 2019 01:09:06 +0700
eksperimental <eksper...@autistici.org> wrote:
> The problem I have with Enum.count_by/2 is that I wouldn't be able just by looking at the name to
> tell it apart from Enum.count/2 which takes a function as a second argument
>
> How will this function work with enumerables other than lists? the way it currently does is
> correct?
>
> iex(6)> Enum.tally %{a: 1, b: 2}
> %{{:a, 1} => 1, {:b, 2} => 1}
>
>
> On Fri, 4 Oct 2019 21:55:09 -0400
> Bruce Tate <br...@grox.io> wrote:
>
> > Count by is excellent. Better than either of the alternatives.
> >
> > -bt
> >
> > On Fri, Oct 4, 2019 at 8:55 PM José Valim <jose...@plataformatec.com.br>
> > wrote:
> >
> > > So I am not a native speaker, but “tally” sounds very foreign to me. Is it
> > > used frequently? I am afraid an uncommon name won’t help with
> > > readability/discovery. Is there a reason why it is not called count_by? It
> > > seems it was first proposed as such to Ruby. Thank you for the proposal!
> > > --
> > >
> > >
> > > *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 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/CAKwTqEk8UxYVPpp9H24YPB0sCNv1_P9nxCALRh7XP2YUsPEJKQ%40mail.gmail.com.
count_by is the first name in ruby's tally proposal.However, it was changed to tally as "quite well to me what this method does and avoids clashing withgroup
orcount
."Of course, count_by is good too.
2019年10月1日火曜日 0時16分17秒 UTC+9 Osawa QWYNG:Hi! Thank you for a great programing language.
This is a suggestion for a new enum function.
Add tally function like Rubys tally.
tally is Rubys 2.7.0 new function
https://bugs.ruby-lang.org/issues/11076
and this is My PR for Elixirhttps://github.com/elixir-lang/elixir/pull/9373
iex> Enum.tally(~w{ant buffalo ant ant buffalo dingo})
%{"ant" => 3, "buffalo" => 2, "dingo" => 1}
iex> Enum.tally(~w{aa aA bb cc}, fn x -> String.downcase(x) end)
%{"aa" => 2, "bb" => 1, "cc" => 1}
The following article is more about this.
https://medium.com/@baweaver/ruby-2-7-enumerable-tally-a706a5fb11ea
Ruby 2.7.0 has not released yet but this function is really good
--
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/hBRKIIy8QKE/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/24503dd9-13ea-4636-88f7-dc2555a869db%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/CADfR9tHCPn0MtRRF5D30CCDnAydq3HM-JTfUVzyV3Gc110e0hg%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/fafa74a1-4a27-4f14-8844-1ecac91ffba2%40googlegroups.com.
Can you please expand what would be a RLE style count?
On Fri, Oct 18, 2019 at 00:43 OvermindDL1 <overm...@gmail.com> wrote:
I personally think the `count_by` name implies some other operation then a grouped count (to me I'd expect an RLE style count), I like the prior mentioned `group_count_by` or `group_count`.--
On Thursday, October 17, 2019 at 2:07:56 PM UTC-6, José Valim wrote:Hi Osawa,Please send a pull request for Enum.count_by:iex> Enum.count_by(~w{aa aA bb cc}, fn x -> String.downcase(x) end)%{"aa" => 2, "bb" => 1, "cc" => 1}It is meant to mirror group_by.If someone has an objection against count_by, please let us know.
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/fafa74a1-4a27-4f14-8844-1ecac91ffba2%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/0796f1bd-afa8-4cbd-b308-180371e9358c%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/fafa74a1-4a27-4f14-8844-1ecac91ffba2%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/20191020083716.01038aeb%40localhostx.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/a5a002ce-b05c-4392-b95d-7a3e00844679%40www.fastmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BWeU%2BYTr-8kK92xD9fTn9PrEgQXGuxs%2BiQC5tcJi1g1w%40mail.gmail.com.