improving the join function
Robert Jacques
sandford at jhu.edu
Mon Oct 11 22:17:15 PDT 2010
On Tue, 12 Oct 2010 00:47:33 -0400, Daniel Gibson <metalcaedes at gmail.com>
wrote:
> On Tue, Oct 12, 2010 at 6:37 AM, Daniel Gibson <metalcaedes at gmail.com>
> wrote:
>>
>> Btw: Is "join" not just a (rather trivial) generalization of reduce?
>>
>> auto inRange = ...; // range of char[]
>> char[] sep = " ";
>> auto joined = reduce!( (char[] res, char[] x) {return res~sep~x;})
>> (inRange);
>>
>
> Not generalization, I meant specialization. (I should probably go to
> bed.)
Well, except for the N memory allocations. Also, for generic ranges you'd
also want to use chain and not "~", but chain won't compose properly in a
reduce.
More information about the Digitalmars-d
mailing list