I like D
Sönke Ludwig via Digitalmars-d
digitalmars-d at puremagic.com
Wed Mar 25 00:58:15 PDT 2015
Am 24.03.2015 um 21:19 schrieb Steven Schveighoffer:
> On 3/24/15 4:11 PM, Andrei Alexandrescu wrote:
>> On 3/24/15 11:56 AM, "Jacques =?UTF-8?B?TcO8bGxlciI=?=
>> <jacques.mueller at gmx.de>" wrote:
>>> On Tuesday, 24 March 2015 at 13:09:21 UTC, Steven Schveighoffer wrote:
>>>> New code:
>>>>
>>>> immutable nfields = header.count('\t');
>>>> ...
>>>> output.writeln(cycle("\t-").take(2 * nfields));
>>>
>>> output.writeln("\t-".repeat(nfields).join);
>>
>> output.writeln("\t-".repeat(nfields).joiner);
>>
>
> Yeah, I looked at repeat first, but it didn't do what I wanted (would
> only repeat a single element).
>
> For some reason, this seems more complex to me. However, it does have
> the benefit of not needing the '2 *'. But I did not think of using
> joiner, nice solution!
>
> -Steve
Also, the shortest solution:
import std.array;
output.writeln("\t-".replicate(nfields));
More information about the Digitalmars-d
mailing list