Thread overview
Docs for `Group` type
Jul 12, 2016
Bahman Movaqar
Jul 12, 2016
Mike Parker
Jul 12, 2016
Bahman Movaqar
Jul 12, 2016
Mike Parker
Jul 12, 2016
Bahman Movaqar
Jul 12, 2016
Edwin van Leeuwen
Jul 12, 2016
Bahman Movaqar
Jul 12, 2016
ag0aep6g
Jul 12, 2016
Bahman Movaqar
July 12, 2016
When using `chunkBy` (unary pred) the result is a list of tuples.  Each
tuple holds a key and a `Group` which belong to that key.
Where can I find the docs for this `Group` type (I have already tried
searching library on dlang.org)?

Thanks,
-- 
Bahman
July 12, 2016
On Tuesday, 12 July 2016 at 04:25:26 UTC, Bahman Movaqar wrote:
> When using `chunkBy` (unary pred) the result is a list of tuples.  Each
> tuple holds a key and a `Group` which belong to that key.
> Where can I find the docs for this `Group` type (I have already tried
> searching library on dlang.org)?
>
> Thanks,

The 'Group' type is an implementation detail -- a type used internally -- that you aren't supposed to care about. All you need to care about is that it's a range. The documentation for chunkBy [1] explains what the return type is.

[1] https://dlang.org/phobos/std_algorithm_iteration.html#.chunkBy
July 12, 2016
On 07/12/2016 11:06 AM, Mike Parker wrote:
> The 'Group' type is an implementation detail -- a type used internally -- that you aren't supposed to care about. All you need to care about is that it's a range. The documentation for chunkBy [1] explains what the return type is.
> 
> [1] https://dlang.org/phobos/std_algorithm_iteration.html#.chunkBy

Thanks.  Now since I can't do `takeOne` on `Group`[1], exactly what kind of range is `Group`?

[1] Error: no property 'takeOne' for type 'Group'

-- 
Bahman
July 12, 2016
On Tuesday, 12 July 2016 at 08:03:53 UTC, Bahman Movaqar wrote:
> On 07/12/2016 11:06 AM, Mike Parker wrote:
>> The 'Group' type is an implementation detail -- a type used internally -- that you aren't supposed to care about. All you need to care about is that it's a range. The documentation for chunkBy [1] explains what the return type is.
>> 
>> [1] https://dlang.org/phobos/std_algorithm_iteration.html#.chunkBy
>
> Thanks.  Now since I can't do `takeOne` on `Group`[1], exactly what kind of range is `Group`?
>
> [1] Error: no property 'takeOne' for type 'Group'

When you downloaded DMD, you also received the source to Phobos, so you can see for yourself. The only Group type I see the chunkBy implementations is at [1] (the link to the github viewer probably won't point to the same place for long, but you should be looking in the the version of ChunkByImpl for forward ranges). It's a forward range.

Do you have some sample code that shows the error?

[1] https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d#L1608
July 12, 2016
On 07/12/2016 01:01 PM, Mike Parker wrote:
> Do you have some sample code that shows the error?

Yes.  I'm working on Stockman[1] a playground to learn D.
In file `etl.d`, line 110 [2], if I change the line to
    auto refInvoice = group[1].takeOne();
the file will not compile.  I have attached the compile error to this
message.

Thanks,
-- 
Bahman


[1] https://github.com/bahmanm/stockman-d
[2] https://github.com/bahmanm/stockman-d/blob/master/source/etl.d#L110


July 12, 2016
On Tuesday, 12 July 2016 at 11:40:48 UTC, Bahman Movaqar wrote:
> On 07/12/2016 01:01 PM, Mike Parker wrote:
>> Do you have some sample code that shows the error?
>
> Yes.  I'm working on Stockman[1] a playground to learn D.
> In file `etl.d`, line 110 [2], if I change the line to
>     auto refInvoice = group[1].takeOne();
> the file will not compile.  I have attached the compile error to this
> message.
>
> Thanks,

What does group.writeln; output? That should give you a good sense of what is going on.
July 12, 2016
On 07/12/2016 01:40 PM, Bahman Movaqar wrote:
> Yes.  I'm working on Stockman[1] a playground to learn D.
> In file `etl.d`, line 110 [2], if I change the line to
>      auto refInvoice = group[1].takeOne();
> the file will not compile.  I have attached the compile error to this
> message.

Do you also add the import of takeOne? takeOne is not a range primitive, but a function that works on ranges. Need to import it in order to use it.
July 12, 2016
On 07/12/2016 04:23 PM, ag0aep6g wrote:
> On 07/12/2016 01:40 PM, Bahman Movaqar wrote:
>> Yes.  I'm working on Stockman[1] a playground to learn D.
>> In file `etl.d`, line 110 [2], if I change the line to
>>      auto refInvoice = group[1].takeOne();
>> the file will not compile.  I have attached the compile error to this
>> message.
> 
> Do you also add the import of takeOne? takeOne is not a range primitive, but a function that works on ranges. Need to import it in order to use it.

Stupid me!  Thanks :-)

-- 
Bahman
July 12, 2016
On 07/12/2016 04:21 PM, Edwin van Leeuwen wrote:
> On Tuesday, 12 July 2016 at 11:40:48 UTC, Bahman Movaqar wrote:
>> On 07/12/2016 01:01 PM, Mike Parker wrote:
>>> Do you have some sample code that shows the error?
>>
>> Yes.  I'm working on Stockman[1] a playground to learn D.
>> In file `etl.d`, line 110 [2], if I change the line to
>>     auto refInvoice = group[1].takeOne();
>> the file will not compile.  I have attached the compile error to this
>> message.
>>
>> Thanks,
> 
> What does group.writeln; output? That should give you a good sense of what is going on.

That's a good trick to know.  Thanks.

-- 
Bahman