Deutsch English Français Italiano |
<ca8014f720972c94150e958ea28a8c70c75978d1@i2pn2.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: dxf <dxforth@gmail.com> Newsgroups: comp.lang.forth Subject: Re: Reverse SCAN SPLIT Date: Fri, 18 Oct 2024 12:10:51 +1100 Organization: i2pn2 (i2pn.org) Message-ID: <ca8014f720972c94150e958ea28a8c70c75978d1@i2pn2.org> References: <5c65a8f1fdfc3e9937a825842fe23dc2758f48ef@i2pn2.org> <nnd$231a8f43$45dbf325@e6f1a2d146514222> <84a43479460314388420efa02405b006aea1677b@i2pn2.org> <nnd$231969a2$24a04042@87f25e33f755b9dd> <nnd$5d969265$1c9f3c75@2ccb8d0b9bcc719d> <73ec4c8359439c78d77d4fce31fc50b2@www.novabbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 18 Oct 2024 01:10:51 -0000 (UTC) Injection-Info: i2pn2.org; logging-data="2515628"; mail-complaints-to="usenet@i2pn2.org"; posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc"; User-Agent: Mozilla Thunderbird Content-Language: en-GB In-Reply-To: <73ec4c8359439c78d77d4fce31fc50b2@www.novabbs.com> X-Spam-Checker-Version: SpamAssassin 4.0.0 On 17/10/2024 9:29 pm, mhx wrote: > On Thu, 17 Oct 2024 8:28:26 +0000, albert@spenarnc.xs4all.nl wrote: > >> In article <nnd$231969a2$24a04042@87f25e33f755b9dd>, > [..] >> Compare to what I'm doing. Promoting the actual API specification >> so that you can decide whether you want to actually use it. >> >> $/ >> >> >> STACKEFFECT: sc c --- sc1 sc2 >> >> DESCRIPTION: [] >> >> Find the first c in the string constant sc and split it at that >> address. Return the strings after and before c into sc1 and sc2 >> respectively. If the character is not present sc1 is a null string >> (its address is zero) and sc2 is the original string. Both sc1 and >> sc2 may be empty strings (i.e. their count is zero), if c is the >> last or first character in sc . > > Wil Baden chose to keep c in sc2. Do you have a reason to > remove it? > > It seems logical to remove it. I normally use lots of > `1 /STRING' and `-LEADING' or `-TRAILING' sequences in further > processing of Split-At-Char results, but not always. > Maybe because an empty sc2 is less informative than an sc2 of > size 1? For Baden's implementation (below) it's easier for the application to discard 'char' than have SPLIT do it. : SPLIT ( str /str char -- str+i /str-i str i ) >R 2dup R> SCAN 2SWAP 2 PICK - ; SCAN is/was a machine-code routine and not readily changeable.