guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Add string-split-substring


From: Christopher Lam
Subject: Re: [PATCH] Add string-split-substring
Date: Sun, 13 Feb 2022 03:28:02 +0000

I think the last test should be:

  (pass-if "string-split-substring - non-empty, trailing delimiters"
    (equal? (string-split-substring "barfoo" "foo")
            (list "bar" ""))))

And isn't it more efficient to use substring/shared instead of substring?

On Sun, 13 Feb 2022 at 03:06, Vijay Marupudi <vijay@vijaymarupudi.com> wrote:
Hello all,

I have added a function named `string-split-substring' to the (ice-9
string-fun) module. It acts like `string-split', but taking a substring
instead. It works like this

(string-replace-substring "item-1::item-2::item-3::item-4" "::")
=> ("item-1" "item-2" "item-3" "item-4")

The tests include all the edge cases in the tests for string-split, and
the behavior matches it exactly.

Documentation is also included in the patch.

I have found myself making and using this function numerous times, and
judging by IRC, others find it useful as well. The patch is attached.

~ Vijay


reply via email to

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