On 12/29/2013 05:17 PM, Andrei Alexandrescu wrote:
On 12/29/13 2:27 AM, bearophile wrote:
But another common need is to group by equivalent classes using an
associative array. Both C# and Clojure have this functionality (on LINQ
and in the functions toolkit). This means that a "hashGroup" builds an
associative array inside and returns it.
See also:
http://d.puremagic.com/issues/show_bug.cgi?id=5968
http://d.puremagic.com/issues/show_bug.cgi?id=9842
I think hash joins should come first.
Andrei
What hash join algorithm do you have in mind that does not use
hashGroupBy as a component?
I think accumAssocArray or similar would be quite handy as well, as it
is more general. A naive implementation r.hashGroupBy!f would then for
example be given by:
r.map!(a=>tuple(f(a),a)) // range of key-value pairs
.accumAssocArray!((a,b)=>a~=b) // method of combination
((ElementType!(typeof(r))[]).init); // initial value