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 (sec
>
> (TL;DR: I'd suggest two functions: one (string-words str)
> function that does Eli's way, and one (string-split str sep) that
> does it Laurent's way).
That would be a good option to me, considering that "my way" is with
remaining ""s in the output list.
The question remains if a string can b
(TL;DR: I'd suggest two functions: one (string-words str)
function that does Eli's way, and one (string-split str sep) that
does it Laurent's way).
50 minutes ago, Eli Barzilay wrote:
> That doesn't seem right -- with this you get
>
> -> (string-split " st ring")
> '("" "st" "" "ring")
>
>
Instead of trying to design a 'string-split' that is both miraculously
intuitive and profoundly flexible, why not design it like a Model-T and
then write a guide/cookbook for how to use regexps to do all of the
common cases that the extremely limited 'string-split' doesn't handle?
I suspect th
> > 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 a
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 w
>
> 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.
>
It would make more sense that a string really is a string,
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 t
[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 som
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 funct
On Thu, Apr 19, 2012 at 14:53, Matthew Flatt wrote:
> At Thu, 19 Apr 2012 14:43:44 +0200, Laurent wrote:
> > On Thu, Apr 19, 2012 at 14:33, Matthew Flatt wrote:
> >
> > > I agree with this: we should add `string-split', the one-argument case
> > > should be as Eli wrote,
> >
> >
> > About this I
At Thu, 19 Apr 2012 14:43:44 +0200, Laurent wrote:
> On Thu, Apr 19, 2012 at 14:33, Matthew Flatt 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
> a
On Thu, Apr 19, 2012 at 14:33, Matthew Flatt 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 between string-as-not-r
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,
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:
>
(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.
On Thu, Apr 19, 2012 at 8:21 AM, Eli Barzilay 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 of a
>> `
[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-spl
18 matches
Mail list logo