Looks like there's a backlog of stuff to finalize for groupBy and aggregate:

* Perhaps rename groupBy to chunkBy. People coming from SQL and other languages might expect groupBy to do hash-based grouping.

* The unary function implementation must return for each group a tuple consisting of the key and the lazy range of values. The binary function implementation should continue to only return the lazy range of values.

* SortedRange should add a method called group(). Invoked with no predicate, group() should do what chunkBy does, using the sorting predicate.

* aggregate() should detect the two kinds of results per group (well, chunk) and process them accordingly: for unary-predicate chunks, pass the key through and only process the lazy range. Meaning:

auto data = [
  tuple("John", 100),
  tuple("John", 35),
  tuple("Jane", 200),
  tuple("Jane", 87),
];
auto r = data.chunkBy!(x => x[0]).aggregate!sum;

yields a range of tuples: tuple("John", 135), tuple("Jane", 187).



Andrei

Reply via email to