Deutsch   English   Français   Italiano  
<84a43479460314388420efa02405b006aea1677b@i2pn2.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: dxf <dxforth@gmail.com>
Newsgroups: comp.lang.forth
Subject: Re: Reverse SCAN SPLIT
Date: Thu, 10 Oct 2024 20:57:43 +1100
Organization: i2pn2 (i2pn.org)
Message-ID: <84a43479460314388420efa02405b006aea1677b@i2pn2.org>
References: <5c65a8f1fdfc3e9937a825842fe23dc2758f48ef@i2pn2.org>
 <nnd$231a8f43$45dbf325@e6f1a2d146514222>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 10 Oct 2024 09:57:45 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="1386116"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc";
User-Agent: Mozilla Thunderbird
In-Reply-To: <nnd$231a8f43$45dbf325@e6f1a2d146514222>
X-Spam-Checker-Version: SpamAssassin 4.0.0
Content-Language: en-GB
Bytes: 2937
Lines: 59

On 10/10/2024 7:00 pm, albert@spenarnc.xs4all.nl wrote:
> In article <5c65a8f1fdfc3e9937a825842fe23dc2758f48ef@i2pn2.org>,
> dxf  <dxforth@gmail.com> wrote:
>> Earlier I mentioned scanning in reverse.  Here's an implementation.
>>
>> [undefined] dxforth [if]
>> : \CHAR ( a u -- a2 u2 c )  1- 2dup + c@ ;
>> [then]
>>
>> \ As for SCAN but scan from end
>> : SCAN< ( a u c -- a2 u2 | a 0 )
>>  >r over swap begin dup while \char r@ = until 1+ then
>>  rot drop rdrop ;
> 
> Compare that with the meticulously designed, exhaustedly specified
> and eminently useful -- $/ -- .
> After 40 years it has not taken over the world ...
> 
> NAME: $/
> 
> 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 .
> (sc is c-addr len )
> 
> 
> The subtle difference between an empty string (a-add 0 ) and
> a null-string ( 0 0 ) allows you to handle empty lines in a file
> gracefully.
> 
> 
>>
>> \ As for SPLIT but scan from end. Latter string is topmost.
>> : SPLIT< ( a u c -- a2 u2 a3 u3 )
>>  >r 2dup r> scan< 2swap 2 pick /string ;
> 
> If you go for SPLIT< from end define SCAN< .
> I have named it $\
>...

I wasn't aware you had reverse split.
I was coming to the conclusion SCAN< as I defined it was of little
value on it's own and planned to subsume it into reverse split.
OTOH a reverse SCAN that gave the same results as forward SCAN might
be useful.

> Get the name of an executable from the source file:
> "aap.frt" &. $\ 2DROP TYPE
> aap OK

I didn't need it for CP/M or DOS but separating filename from filetype
in Windows would be easier when scanned from the end.