array to string functional?
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Sat Sep 15 05:42:54 UTC 2018
On Friday, September 14, 2018 11:39:48 PM MDT berni via Digitalmars-d-learn
wrote:
> On Saturday, 15 September 2018 at 03:25:38 UTC, Paul Backus wrote:
> > On Friday, 14 September 2018 at 20:43:45 UTC, SrMordred wrote:
> >> What you want is std.range.chunks
> >>
> >>
> >> auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0];
> >>
> >> a.map!(to!string)
> >>
> >> .join("")
> >> .chunks(4)
> >> .map!(to!string) //don´t know why the chunks are not
> >>
> >> already strings at this point ;/
> >>
> >> .writeln;
> >
> > It's easier if you chunk before joining:
> >
> > auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0];
> >
> > a.map!(to!string)
> >
> > .chunks(4)
> > .map!join
> > .writeln;
>
> Oh, thanks. What I didn't know about was join. Now I wonder how I
> could have found out about it, without asking here? Even yet I
> know it's name I cannot find it, nighter in the language
> documentation nor in the library documentation.
https://dlang.org/phobos/std_array.html#join
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list