Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: dxf Newsgroups: comp.lang.forth Subject: Re: Reverse SCAN SPLIT Date: Fri, 18 Oct 2024 12:10:51 +1100 Organization: i2pn2 (i2pn.org) Message-ID: References: <5c65a8f1fdfc3e9937a825842fe23dc2758f48ef@i2pn2.org> <84a43479460314388420efa02405b006aea1677b@i2pn2.org> <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 Bytes: 2559 Lines: 38 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 , > [..] >> 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.