[Changed title to talk about each one separately.]

Two hours ago, Laurent wrote:
> One string function that I often find useful in various scripting
> languages is a `string-split' (explode in php).  It can be done with
> `regexp-split', but having something more along the lines of a
> `string-split' should belong to a racket/string lib I think.  Plus
> it would be symmetric with `string-join', which already is in
> racket/ string (or at least a doc line pointing to regexp-split
> should be added there).

If you mean something like this:

  (define (string-split str) (regexp-match* #px"\\S+" str))


If so, then I see a much weaker point for it -- unlike other small
utilities, this one doesn't even compose two function calls.

The very weak point here is if you want a default argument that
specifies the gaps to split on rather than the words:

  (define (string-split str [sep #px"\\s+"])
    (remove* '("") (regexp-split sep str)))

but that *does* use regexps, so I don't see the point, still...

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

  Racket Developers list:

Reply via email to