[WORK] groupBy is in! Next: aggregate
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jan 26 10:05:21 PST 2015
On 1/26/15 9:50 AM, Ary Borenszweig wrote:
> On 1/26/15 2:34 PM, Andrei Alexandrescu wrote:
>> On 1/26/15 8:11 AM, H. S. Teoh via Digitalmars-d wrote:
>>> On Mon, Jan 26, 2015 at 11:26:04AM +0000, bearophile via Digitalmars-d
>>> wrote:
>>>> Russel Winder:
>>>>
>>>>> but is it's name "group by" as understood by the rest of the world?
>>>>
>>>> Nope...
>>> [...]
>>>
>>> I proposed to rename it but it got shot down. *shrug*
>>>
>>> We still have a short window of time to sort this out, before 2.067 is
>>> released...
>>
>> My suggestion was to keep the name but change the code of your groupBy
>> implementation to return tuple(key, lazyValues) instead of just
>> lazyValues. That needs to happen only for binary predicates; unary
>> predicates will all have alternating true/false keys.
>>
>> Seems that would please everyone.
>>
>>
>> Andrei
>>
>
> That's much more harder to implement than what it does right now. I
> don't know how you'll manage to do the lazyValues thing: you'd need to
> make multiple passes in the range.
The implementation right now is quite interesting but not complicated,
and achieves lazy grouping in a single pass.
> Again, other languages return an associative array in this case.
I think our approach is superior.
Andrei
More information about the Digitalmars-d
mailing list