[racket-dev] `string-split'

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Apr 19 09:27:17 EDT 2012

Just now, Laurent wrote:
>     1. Laurent: Does this make more sense?
> 
> Yes, this definitely makes more sense to me.  It would then treat
> (string-split "aXXbXXXXy" "X") just like the " " case.
> 
> Although if you want to find the columns of a latex line like "x &&
> y & z" you will have the wrong result.  Maybe use an optional
> argument to remove the empty strings? (not sure)

(This complicates things...)

First, I don't think that there's a need to make it able to do stuff
like that -- either you go with regexps, or you use combinations like

  (map string-trim (string-split "x && y & z" "&"))


>     4. Related to Q3: what does "xy" as that argument mean exactly?
>       a. #rx"[xy]"
>       b. #rx"[xy]+"
>       c. #rx"xy"
>       d. #rx"(?:xy)+"
> 
> Good question. d. would be the simplest case for newbies, but
> b. might be more useful.  I think several other languages avoid this
> issue by using only one character as the separator.

The complication is that with " " or " \t" it seems that you'd want b,
and with "&" you'd want c.  (Maybe even make "&" equivalent to
#rx" *& *" -- that looks like it's too much guessing.)

And you're also making a point for:

  e. Throw an error, must be a single-character string.

BTW, this question is important because it affects other functions, so
I'd like to resolve it before doing anything.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.