Re: core/group-by with optional value-mapper function

2012-12-20 Thread Alex Walker
Realized I forgot to include an example of how the code I linked to can be used to solve the original problem, which will make it clearer how it is used. https://gist.github.com/4349972 But when writing that example, I remembered why I created factory-style functions. The group-by from Daniel

Re: core/group-by with optional value-mapper function

2012-12-20 Thread Alex Walker
I like the idea of it being built-in and might prefer that approach, however, I wanted to share an alternative. https://gist.github.com/4346395 I needed to take a denormalized table of config data and create a nested lookup map, so that I wouldn't need to repeatedly filter the dataset while us

Re: core/group-by with optional value-mapper function

2012-12-17 Thread Alex Baranosky
I think it sounds like a nice addition, after mulling it over a little. On Mon, Dec 17, 2012 at 4:47 AM, László Török wrote: > Hi, > > I have come across use cases in the past where an additional > transformation step was indeed very handy and I wrote my own version of > group-by, one identical

Re: core/group-by with optional value-mapper function

2012-12-17 Thread László Török
Hi, I have come across use cases in the past where an additional transformation step was indeed very handy and I wrote my own version of group-by, one identical to Daniel's. Maybe a function worthwhile for c.c.incubator. Las 2012/12/17 Daniel Dinnyes > Also note that I wrote in my first post

Re: core/group-by with optional value-mapper function

2012-12-17 Thread Daniel Dinnyes
Also note that I wrote in my first post that "Without the value-mapper argument it is very awkward to achieve the same structure after the group-by call". The `map-vals` function is almost the closest you can get to map values after a group-by in a streamlined and clean manner. There is ` fmap

Re: core/group-by with optional value-mapper function

2012-12-17 Thread Daniel Dinnyes
Hi, I expect the cost of calling `identity` to be negligible. Not for sure, but the JVM might even inline it at run-time, or there might be optimizations for it in clojure.core during compilation... I cannot comment on that. But even with a full virtual call, it should be faster than iterating

core/group-by with optional value-mapper function

2012-12-14 Thread Daniel Dinnyes
Hi, I would like to suggest an enhancement to the clojure.core/group-by function. The idea came from using Enumerable.GroupBy extension method in .NET quite much. It is really handy to have an optional value-mapper function which transfo