Splitter quiz / survey -- PLEASE NO

Derek Parnell derek at psych.ward
Mon Apr 27 15:27:04 PDT 2009


On Mon, 27 Apr 2009 15:12:59 -0700, Walter Bright wrote:

> Andrei Alexandrescu wrote:
>> I have been convinced. I will modify splitter to do (4), i.e., prepend 
>> or append an empty element if there's a leading, respectively trailing, 
>> separator. Thanks to all for destroying me :o).
> 
> Looks like I must concede, too <g>.

The utility of a function that treats the delimiter as a teminator is still
a good idea, but it would need a name that is not derived from "split". I'm
struggling to think of one but so far something like "itemize" is coming
closer to my expectations.

Also, the documentation for splitter must say that the delimiter is being
treated as a separator between items and thus the presence of a delimiter
implies that an item exists before AND after the delimiter (because it is
inbetween two items, by definition).

The documentation for "itemize" (or whatever) must say that the delimiter
is being treated as a terminator of an item. The presence of a delimiter
thus implies that an item must exist before the delimiter (because it marks
the end of an item, by definition). The only weirdo situation is then what
to do with an item that is not terminated by a delimiter, that is the last
one in the list. Ok, so we say that the list of items is seen as one in
which each item is terminated by the delimiter or by the end of the list.

On the other hand, "itemize" is kind of like ...

  split(trim(list, delim), delim)


-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list