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")

Regards,
Sjoerd


Reply via email to