From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Lam Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Add string-split-substring Date: Sun, 13 Feb 2022 03:28:02 +0000 Message-ID: References: <87tud3qxdo.fsf@vijaymarupudi.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c7abb105d7dde4f0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36834"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel To: Vijay Marupudi Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Feb 13 04:28:54 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJ5ZG-0009PB-9Z for guile-devel@m.gmane-mx.org; Sun, 13 Feb 2022 04:28:54 +0100 Original-Received: from localhost ([::1]:46120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJ5ZE-0002LS-S0 for guile-devel@m.gmane-mx.org; Sat, 12 Feb 2022 22:28:52 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJ5Z1-0002LK-8W for guile-devel@gnu.org; Sat, 12 Feb 2022 22:28:39 -0500 Original-Received: from [2607:f8b0:4864:20::b2f] (port=34400 helo=mail-yb1-xb2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJ5Yz-0002fq-A9 for guile-devel@gnu.org; Sat, 12 Feb 2022 22:28:38 -0500 Original-Received: by mail-yb1-xb2f.google.com with SMTP id v186so36540878ybg.1 for ; Sat, 12 Feb 2022 19:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RPyZbSIlpeWC86KqcYtyvkNT9trX1YOJEXA96fncOKU=; b=qIPCfJ7sVUDlwdL+Q7PVMzx0WkVmJBRrP7SPoGoIZsaEg3X/SS6z5H2hwg8UPF0rNC ELYRUdJfbOKDwtS2x1H4bNHz8IUoY4k7wgQbmuOlhMfZTW4bpSESwFQ8/Vc3PzDew6IC BPZekfJKmWVUa6/HCpZ46XYfRMi8ZtyYIrov2Q3Kx5PS0/EKqvuLhkY8DP+RZrRxA+ZY Q5my6e0Wlr8D3w5vxDA37Uy+xKYelVY3/ZkyzZI27H8VWp708BFFnwper97j4d0p52GS mQjOM5HJKzG3RdvZwooxg0bqejxv7VvuBqGzFnVgF8ns0kn6YwEYs0Wabj6dZWRurrQ+ 6LVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RPyZbSIlpeWC86KqcYtyvkNT9trX1YOJEXA96fncOKU=; b=jhX3kwdUDDMiA8spT3SrcBg6MLGNvW5iE094dCOuNQ8avfmxmM6/D9IOXQ62vDy/mO 3dyj0AnSAM3MfezGjEg3ekq67XTBadDPeU1zrww1ZwUzYUA+e9Aob6wPb0d/T0UWk5lD 2NKy70ZGq5iXbUjBH3fSow5xHrCrEKniKrb/sdwAFVlj5W3cWcwiLWvMCxrGE8tWrQLo HqrwYKtjiYVcJadG1DScIopp7gTP98LQn1Hlm6inJrz7YH6xt46BUQ0JMTUxkoGTZPE9 b7zgEYk3lRHjn5QyavuwSxRPSykKy1H9djs+T1Ec7mQY/Y5zg+FxwBl4hEwST/do7WIO kixw== X-Gm-Message-State: AOAM532PLmLPcJaVc8rrd7MNwmmX3wYcK7ziCLbIbMT+A/uCXOb2yUZZ gR34JEFVF+1BPQITdXuF9GH0WeQyURbz37toFfNdD65AlTBX2Q== X-Google-Smtp-Source: ABdhPJw4nUOsOPqz3flfgCX03vcAx0KgtIJWqzbbUJKICmu5i+Y9VMxxNeLtNjraZ4aw2k6iNhdrbn+QeCsBx5EyfQA= X-Received: by 2002:a0d:f405:: with SMTP id d5mr8345984ywf.107.1644722909586; Sat, 12 Feb 2022 19:28:29 -0800 (PST) In-Reply-To: <87tud3qxdo.fsf@vijaymarupudi.com> X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::b2f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::b2f; envelope-from=christopher.lck@gmail.com; helo=mail-yb1-xb2f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21106 Archived-At: --000000000000c7abb105d7dde4f0 Content-Type: text/plain; charset="UTF-8" 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 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 > > --000000000000c7abb105d7dde4f0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think the last test should be:

=
=C2=A0 (pass-if "string-split-substring - non-empty, trailing del= imiters"
=C2=A0=C2=A0=C2=A0 (equal? (string-split-substring "b= arfoo" "foo")
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2= =A0 (list "bar" ""))))

And isn= 't it more efficient to use substring/shared instead of substring?
<= /div>

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" "= ::")
=3D> ("item-1" "item-2" "item-3" "ite= m-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

--000000000000c7abb105d7dde4f0--