Skip to content
Prev 29262 / 63424 Next

strsplit and the empty string

Oh my, I regret my stupidity.
Christian Brechb?hler wrote:
of course, that was my test code.
the problem is that one needs to check for the empty string at the
beginning, if there could be one in the output.  perhaps an additional
logical argument to strsplit would be useful, e.g., 'reduce', 'sparse',
or whatever the name.
that was what i should have written.  that was all too hasty.
there's where my stupidity becomes apparent, i'm afraid ,(
indeed, i must have mistyped while checking it.  so the results in a few
other languages are:

3 elements: java (and groovy), oz
4 elements: python, javascript, php, boo
2 elements: ruby,

while they are not mutually coherent, the last two approaches are at
least symmetric, which i find much more intuitive.

thanks for the reponse.  a good lesson ;)

vQ