Re: Output range of ranges to single buffer

2016-01-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-01-14 17:59, Ali Çehreli wrote: Here is an experiment that wraps the third party type to provide a lazy toString: import std.stdio; import std.format; import std.array; import std.algorithm; import std.range; /* Wraps an element and provides a lazy toString that dispatches the work to

Re: Output range of ranges to single buffer

2016-01-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 14, 2016 08:41:23 Jacob Carlborg via Digitalmars-d-learn wrote: > On 2016-01-13 22:20, H. S. Teoh via Digitalmars-d-learn wrote: > > > Isn't that just a matter of replacing each of the segments with their > > range equivalents? Also, std.format.formattedWrite will do > > write

Re: Output range of ranges to single buffer

2016-01-14 Thread Ali Çehreli via Digitalmars-d-learn
On 01/13/2016 11:41 PM, Jacob Carlborg wrote: > what if I need to format a third party type that I cannot add > methods to? UFCS does not seem to work. Here is an experiment that wraps the third party type to provide a lazy toString: import std.stdio; import std.format; import std.array; impo

Re: Output range of ranges to single buffer

2016-01-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-01-13 22:20, H. S. Teoh via Digitalmars-d-learn wrote: Isn't that just a matter of replacing each of the segments with their range equivalents? Also, std.format.formattedWrite will do writeln-formatting into a buffer (well, any output range, really) -- I'm pretty sure it doesn't allocate

Re: Output range of ranges to single buffer

2016-01-13 Thread Ali Çehreli via Digitalmars-d-learn
On 01/13/2016 01:20 PM, H. S. Teoh via Digitalmars-d-learn wrote: std.format.formattedWrite will do writeln-formatting into a buffer (well, any output range, really) -- I'm pretty sure it doesn't allocate, at least for the simplest cases like converting an integer. So you should be able to do so

Re: Output range of ranges to single buffer

2016-01-13 Thread Dav1d via Digitalmars-d-learn
On Wednesday, 13 January 2016 at 21:15:03 UTC, Jacob Carlborg wrote: Is it possible to somehow output a range of ranges to a single string buffer? For example, converting an array of integers to a string with the same representation as the source code. [...] std.format can do it. From the si

Re: Output range of ranges to single buffer

2016-01-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 13, 2016 at 10:15:03PM +0100, Jacob Carlborg via Digitalmars-d-learn wrote: > Is it possible to somehow output a range of ranges to a single string > buffer? For example, converting an array of integers to a string with > the same representation as the source code. > > import std.algo