[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regexp-split for Guile

From: Sjoerd van Leent Privé
Subject: Re: regexp-split for Guile
Date: Tue, 18 Sep 2012 09:06:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0

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)
     => ("foo" "bar" "baz:qux:")

2. Negative limit: Return all fields:

     (regexp-split ":" "foo:bar:baz:qux:" -1)
     => ("foo" "bar" "baz" "qux" "")

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)
=> ("foo:bar" "baz" "qux" "")

This is practical for paths etc.

The problem described in your second case could be solved by using a symbol, such as #:all, or something similar.

3. Zero limit: Return all fields, after removing trailing blank fields:

     (regexp-split ":" "foo:bar:baz:qux:" 0)
     => ("foo" "bar" "baz" "qux")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]