Re: Stuck with std.algorithm.splitter

2011-04-03 Thread Aleksandar Ružičić
On Mon, Apr 4, 2011 at 2:30 AM, Jonathan M Davis wrote: > On 2011-04-03 17:19, Aleksandar Ružičić wrote: >> I definitely must sit down and read about ranges, as it seems I don't >> quite get what exactly they are (and what types of ranges exists and >> the difference between them).. >> >> > auto p

Re: Stuck with std.algorithm.splitter

2011-04-03 Thread Jonathan M Davis
On 2011-04-03 17:19, Aleksandar Ružičić wrote: > I definitely must sit down and read about ranges, as it seems I don't > quite get what exactly they are (and what types of ranges exists and > the difference between them).. > > > auto parts = array(splitter(input, '|')); > > That's a nice solution

Re: Stuck with std.algorithm.splitter

2011-04-03 Thread Aleksandar Ružičić
I haven't even looked into std.array... sorry.. So I won't need custom function after all. Thanks!

Re: Stuck with std.algorithm.splitter

2011-04-03 Thread Aleksandar Ružičić
I definitely must sit down and read about ranges, as it seems I don't quite get what exactly they are (and what types of ranges exists and the difference between them).. > > auto parts = array(splitter(input, '|')); > That's a nice solution! I wasn't aware of array() though.. But I would like to

Re: Stuck with std.algorithm.splitter

2011-04-03 Thread bearophile
Aleksandar R.: > I want to split a string into an array of strings. As much as it seems > trivial I just can't make it work. > > This is code I use for splitting: > > - > auto input = "foo|bar"; // sample input string > auto parts = spl

Re: Stuck with std.algorithm.splitter

2011-04-03 Thread Jonathan M Davis
On 2011-04-03 16:34, Aleksandar Ružičić wrote: > I want to split a string into an array of strings. As much as it seems > trivial I just can't make it work. > > This is code I use for splitting: > > - > auto input = "foo|bar"; // sample

Re: Stuck with std.algorithm.splitter

2011-04-03 Thread Aleksandar Ružičić
Ok, here is my function which works as expected: --- string[] explode(in string source, char separator) { typeof(return) result; size_t prev = 0; foreach (i, c; source) { if (c == separator) {

Stuck with std.algorithm.splitter

2011-04-03 Thread Aleksandar Ružičić
I want to split a string into an array of strings. As much as it seems trivial I just can't make it work. This is code I use for splitting: - auto input = "foo|bar"; // sample input string auto parts = splitter(input, '|'); // split by