std.algorithm.splitter improovement?

Dmitry Olshansky dmitry.olsh at gmail.com
Sat Dec 14 12:37:45 PST 2013


14-Dec-2013 21:20, bearophile пишет:
> Marco Leise:
>
>> Not at all, the documentation explicitly states:
>>
>>   assert(equal(splitter("hello  world", ' '), [ "hello", "", "world" ]));
>
> I didn't see the ' ' in the OP code, sorry.
>
> A test:
>
>
> void main() {
>      import std.stdio, std.string, std.algorithm;
>      auto s = "hello  world";
>      s.split().writeln;
>      std.array.splitter(s).writeln;
>      s.splitter(' ').writeln;
> }
>
>
> The output seems OK:

Yup, there are 2 splitters - one that uses explicit separator and one 
that uses predicate. AFAIK the default predicate is std.uni.isWhite.

> ["hello", "world"]
> ["hello", "world"]
> ["hello", "", "world"]
>
> Bye,
> bearophile


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list