Thread overview |
---|
June 17, 2009 Using to! ? | ||||
---|---|---|---|---|
| ||||
Hi, Given the example below: string str = "1 2 3 4 5 6"; double[] numbers = to!(double[])(split(str)); writefln(to!string(numbers)); I get [1, 2, 3, 4, 5, 6] which is okay. How do I output it with different separators? What I would like to get is [ 1 2 3 4 5 6 ] or ( 1 2 3 4 5 6 ). unknown |
June 17, 2009 Re: Using to! ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to unknown | unknown Wrote: > Hi, > > Given the example below: > string str = "1 2 3 4 5 6"; > double[] numbers = to!(double[])(split(str)); > writefln(to!string(numbers)); > > I get [1, 2, 3, 4, 5, 6] which is okay. > > How do I output it with different separators? > > What I would like to get is [ 1 2 3 4 5 6 ] or ( 1 2 3 4 5 6 ). > > unknown > > This: writeln(std.conv.to!string(numbers, "( ", " ", " )")); Will output: ( 1 2 3 4 5 6 ) And writeln(std.conv.to!string(numbers, "<< ", " | ", " >>")); Will result in: << 1 | 2 | 3 | 4 | 5 | 6 >> |
June 17, 2009 Re: Using to! ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to unknown | unknown Wrote:
Figured it out.
Forget it.
> Hi,
>
> Given the example below:
> string str = "1 2 3 4 5 6";
> double[] numbers = to!(double[])(split(str));
> writefln(to!string(numbers));
>
> I get [1, 2, 3, 4, 5, 6] which is okay.
>
> How do I output it with different separators?
>
> What I would like to get is [ 1 2 3 4 5 6 ] or ( 1 2 3 4 5 6 ).
>
> unknown
>
>
|
June 17, 2009 Re: Using to! ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | John C Wrote:
Thanks John,
I already figured it out.
There should be an example in the unit tests.
Cheers,
unknown
> unknown Wrote:
>
> > Hi,
> >
> > Given the example below:
> > string str = "1 2 3 4 5 6";
> > double[] numbers = to!(double[])(split(str));
> > writefln(to!string(numbers));
> >
> > I get [1, 2, 3, 4, 5, 6] which is okay.
> >
> > How do I output it with different separators?
> >
> > What I would like to get is [ 1 2 3 4 5 6 ] or ( 1 2 3 4 5 6 ).
> >
> > unknown
> >
> >
>
> This:
> writeln(std.conv.to!string(numbers, "( ", " ", " )"));
>
> Will output:
> ( 1 2 3 4 5 6 )
>
> And
> writeln(std.conv.to!string(numbers, "<< ", " | ", " >>"));
>
> Will result in:
> << 1 | 2 | 3 | 4 | 5 | 6 >>
|
Copyright © 1999-2021 by the D Language Foundation