On Sun, Oct 21, 2012 at 04:20:09PM +0800, Daniel Hartwig wrote:
> Yes. Keep it simple. Operations like trim-whitespace and
> drop-empty-strings-from-the-result (mentioned in the previous
> discussion) are so easy to do outside of regexp-split, why complicate
> the semantics?
"So easy", but so ve
On Sat, Oct 20, 2012 at 10:16:49AM -0400, Mark H Weaver wrote:
> Sorry, that last example is wrong of course, but both of these examples
> raise an interesting question about how #:limit and #:trim should
> interact. To my mind, the top example above is correct. I think the
> last result should b
On 20 October 2012 22:16, Mark H Weaver wrote:
> Honestly, this question makes me wonder if the proposed 'regexp-split'
> is too complicated. If you want to trim whitespace, how about using
> 'string-trim-right' or 'string-trim-both' before splitting? It seems
> more likely to do what I would ex
I wrote:
> (regexp-split " +" " foo bar baz " #:limit 3 #:trim 'both)
> => ("foo" "bar" "baz")
> (regexp-split " +" " foo bar baz " #:limit 2 #:trim 'both)
> => ("foo" "bar")
Sorry, that last example is wrong of course, but both of these examples
raise an interesting qu
Hi Chris,
"Chris K. Jester-Young" writes:
> On Fri, Oct 12, 2012 at 05:57:11PM -0400, Mark H Weaver wrote:
>> Beyond matters of taste, I don't like this because it makes bugs less
>> likely to be caught. Suppose 'limit' is a computed value, normally
>> expected to be positive. Code that follows
On Fri, Oct 12, 2012 at 05:57:11PM -0400, Mark H Weaver wrote:
> FWIW, I agree with Daniel. I dislike the complicated semantics of this
> 'limit' argument, which combines into a single number two different
> concepts:
First, I want to thank both Daniel and Mark for their feedback. I'm
sorry I hav
Daniel Hartwig writes:
> On 19 September 2012 03:59, Chris K. Jester-Young wrote:
>> (define* (regexp-split pat str #:optional (limit 0))
>> […]
>> (reverse (if (zero? limit)
>> (drop-while string-null? final)
>> final
>>
>
> Please simplify this limit ar
On 19 September 2012 03:59, Chris K. Jester-Young wrote:
> (define* (regexp-split pat str #:optional (limit 0))
> […]
> (reverse (if (zero? limit)
> (drop-while string-null? final)
> final
>
Please simplify this limit arg, removing the maybe-drop-empty-st
Hi Chris,
"Chris K. Jester-Young" skribis:
> I'm currently implementing regexp-split for Guile, which provides a
> Perl-style split function (including correctly implementing the "limit"
> parameter), minus the special awk-style whitespace handling (that i
On Tue, 2012-09-18 at 15:55 -0400, Chris K. Jester-Young wrote:
> On Tue, Sep 18, 2012 at 08:59:33PM +0800, nalaginrut wrote:
> > Anyway, if there're so many people like this nice thing, why not we add
> > it (at any option of these three implementations) into ice-9?
>
> Oh noes! This is where th
Here's a revised version, implementing Thien-Thi Nguyen's comments. I
added line breaks for the "cons" and the bottom "if" (I feel that the
top "if" is still simple enough to keep on the same line).
Cheers,
Chris.
* * *
(define (regexp-split-fold match prev)
On Tue, Sep 18, 2012 at 08:59:33PM +0800, nalaginrut wrote:
> Anyway, if there're so many people like this nice thing, why not we add
> it (at any option of these three implementations) into ice-9?
Oh noes! This is where the bikeshedding begins. ;-)
Seriously, I do think having a regexp-split in
On Tue, Sep 18, 2012 at 09:06:55AM +0200, Sjoerd van Leent Privé wrote:
> It might just be me, but would it not be more sensible for scheme to
> just perform the opposite. Return the same amount of fields at most,
> but starting from the end, thus:
>
> (regexp-split ":" "foo:bar:baz:qux:" -3)
> =>
it (at any option of these three implementations) into ice-9?
On Mon, 2012-09-17 at 10:01 -0400, Chris K. Jester-Young wrote:
> Hi there,
>
> I'm currently implementing regexp-split for Guile, which provides a
> Perl-style split function (including correctly implementing the &quo
Hi Chris,
I have been following your thread about regexp-split. I do have some
thoughts about this to make the interface more versalite.
So, basically, the Perl split's limit is used this way:
1. Positive limit: Return this many fields at most:
(regexp-split ":" "foo:bar:baz:qux:" 3)
On Mon, Sep 17, 2012 at 09:32:14PM +0200, Thien-Thi Nguyen wrote:
>(define (string-empty? str)
> (zero? (string-length str)))
>
> You can use ‘string-null?’ instead.
Ah, nice! Thanks for the pointer.
> Style nit: i find it easier to read ‘if’ expressions w/ the condition,
> then and els
() "Chris K. Jester-Young"
() Mon, 17 Sep 2012 10:01:33 -0400
(define (string-empty? str)
(zero? (string-length str)))
You can use ‘string-null?’ instead.
(define* (regexp-split pat str #:optional (limit 0))
(let* ((result (fold-matches pat str '(0) regexp-split-fold 0
Hi there,
I'm currently implementing regexp-split for Guile, which provides a
Perl-style split function (including correctly implementing the "limit"
parameter), minus the special awk-style whitespace handling (that is
used with a pattern of " ", as opposed to / /, with
18 matches
Mail list logo