On Sunday, 14 October 2012 at 20:09:44 UTC, Peter Alexander wrote:
Well, for example:
splitter("hello world", ' ')
gives
["hello", "world"]
The splits are slices of the original range.
splitter could allocate new ranges, but if you want that
behaviour then it's better to specify it manually:
chain(repeat("a").take(5),
repeat("b").take(5)).array().splitter("b");
That works, giving:
[["a", "a", "a", "a", "a"], [], [], [], [], []]
I wonder if a better design for splitter would automatically
allocate an array when the input range doesn't support slicing?
Oh I didn't realize that, it's because it wants to slice the
original range...
Yeah, I think that might not be such a bad idea. It should be
possible to slice infinite ranges too, after all.