[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'
On Thu, Apr 19, 2012 at 8:21 AM, Eli Barzilay e...@barzilay.org wrote:
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
(define (string-split str [sep #px\\s+])
(remove* '() (regexp-split sep str)))
Nearly, I meant something more like this:
(define (string-split str [splitter ])
(regexp-split (regexp-quote splitter) str))
No regexp from the user POV, and much easier to use with little knowledge.
I agree with this: we should add `string-split', the one-argument case
should be as Eli wrote, and the two-argument case should be as Laurent
wrote. (Probably the optional second argument should be string-or-#f,
where #f means to use #px\\s+.)
At Thu, 19 Apr 2012 14:30:31 +0200, Laurent wrote:
I think Laurent pointed out in his initial message that beginners may be
intimidated by regexps. I agree. Plus someone who isn't fluent with regexp may
be more comfortable with string-split. Last but not least, a program documents
itself more clearly with string-split vs regexp.
On Apr 19,
On Thu, Apr 19, 2012 at 14:33, Matthew Flatt mfl...@cs.utah.edu wrote:
I agree with this: we should add `string-split', the one-argument case
should be as Eli wrote,
About this I'm not sure, as one cannot reproduce this behavior by providing
an argument (or it could make the difference
At Thu, 19 Apr 2012 14:43:44 +0200, Laurent wrote:
On Thu, Apr 19, 2012 at 14:33, Matthew Flatt mfl...@cs.utah.edu wrote:
I agree with this: we should add `string-split', the one-argument case
should be as Eli wrote,
About this I'm not sure, as one cannot reproduce this behavior by
On Thu, Apr 19, 2012 at 14:53, Matthew Flatt mfl...@cs.utah.edu wrote:
At Thu, 19 Apr 2012 14:43:44 +0200, Laurent wrote:
On Thu, Apr 19, 2012 at 14:33, Matthew Flatt mfl...@cs.utah.edu wrote:
I agree with this: we should add `string-split', the one-argument case
should be as Eli
A few minutes ago, Laurent wrote:
Then instead of #f one idea is to go one step further and consider
different useful cases based on input symbols like 'whitespaces,
'non-alpha, etc. ? Or even a list of string/symbols that can be used
as a splitter. That would make a more powerful function
[Meta-note: I'm not just flatly object to these, just trying to
clarify the exact behavior and the possible effects on other
functions.]
10 minutes ago, Laurent wrote:
(define (string-split str [sep #px\\s+])
(remove* '() (regexp-split sep str)))
Nearly, I meant something
Continuing with this line, it seems that a better definition is as
follows:
(define (string-split str [sep ])
(remove* '() (regexp-split (regexp-quote (or sep )) str)))
Except that the full definition could be a bit more efficient.
Three questions:
1. Laurent: Does this make more
4. Related to Q3: what does xy as that argument mean exactly?
a. #rx[xy]
b. #rx[xy]+
c. #rxxy
d. #rx(?:xy)+
Good question. d. would be the simplest case for newbies, but b. might be
more useful.
It would make more sense that a string really is a string, not a set of
characters.
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 aXXby 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.
An hour and a half ago, Ryan Culpepper wrote:
Instead of trying to design a 'string-split' that is both
miraculously intuitive and profoundly flexible, why not design it
like a Model-T
Invalid analogy: the issue is not flexibility, it's making something
that is simple (first) and useful
14 matches
Mail list logo