On Sat, 23 Jun 2012 17:19:59 +0200, Chad J
<chadjoan@__spam.is.bad__gmail.com> wrote:
http://dlang.org/phobos/std_array.html#splitter
The first thing I don't understand is why splitter is in /std.array/ and
yet only works on /strings/. It is defined > in terms of whitespace,
and I don't understand how whitespace is well-defined for things besides
text. Why wouldn't > it be in std.string?
See http://dlang.org/phobos/std_algorithm.html#splitter
I would expect these functions to exist:
auto getHead(C)(C[] s, C[] delim, ref C[] tail);
auto getHead(C)(C[] s, C[] delim);
auto getTail(C)(C[] s, C[] delim);
As head is simply splitter(..)[0] and tail splitter(...)[1..$], extra
functions could be implemented much like this
@property T head(T[] arr) { return arr.front; }
@property T[] tail(T[] arr) { return arr[1..$]; }
..and UFCS takes care of the rest:
auto fields = splitter(...);
auto head = fields.head;
auto tail = fields.tail;