Today's programming challenge - How's your Range-Fu ?

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 18 13:32:55 PDT 2015


On Fri, Apr 17, 2015 at 08:44:51PM +0000, Panke via Digitalmars-d wrote:
> On Friday, 17 April 2015 at 19:44:41 UTC, ketmar wrote:
> >On Fri, 17 Apr 2015 11:17:30 -0700, H. S. Teoh via Digitalmars-d wrote:
> >
> >>Well, talk is cheap, so here's a working implementation of the
> >>non-Unicode-correct line wrapper that uses ranges and does not
> >>allocate:
> >
> >there is some... inconsistency: `std.string.wrap` adds final "\n" to
> >string. ;-) but i always hated it for that.
> 
> A range of lines instead of inserted \n would be a good API as well.

Indeed, that would be even more useful, then you could just do
.joiner("\n") to get the original functionality.

However, I think Walter's goal here is to match the original wrap()
functionality.

Perhaps the prospective wrapped() function could be implemented in terms
of a byWrappedLines() function which does return a range of wrapped
lines.


T

-- 
The volume of a pizza of thickness a and radius z can be described by the following formula: pi zz a. -- Wouter Verhelst


More information about the Digitalmars-d mailing list