[racket-dev] Very quick poll re `string-trim'
Did you consider an optional argument to string-trim?
Robby
On Fri, May 11, 2012 at 6:53 AM, Eli Barzilay <eli at barzilay.org> wrote:
> Should (string-trim str sep) remove any number of `sep' matches or
> just one? (This makes no difference for the default `sep' since it's
> #px"\\s+".) Possible options below, feel free to mail me off-list to
> reduce noise.
>
> 1. Yes.
> * Advantage: makes life with string separator a bit easier. For
> example, remove only newlines with (string-trim str "\n")
> * Disadvantage: can be confusing with strings or regexps like "xy".
> For example:
> (string-trim ", , foo, bar, " #rx", *") => "foo, bar"
>
> 2. No. Flipped dis/advantages.
>
> 3. Yes for string separators, no for (p)regexp separators. Tries to
> get both advantages, but at the cost of non-uniform behavior.
>
> I'm leaning towards #2 since (a) it's less surprising in the regexp
> and >=2 string cases, and (b) it'll make similar to other functions
> like `string-split' where an implicit repetition is a bad idea (eg,
> when you split with "," you'd usually want that to mean #rx"," not
> #rx",+"). OTOH, I hate to loose the possibly useful case of
> 1-character strings.
>
> --
> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
> http://barzilay.org/ Maze is Life!
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev