Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.forth    |    Forth programmers eat a lot of Bratwurst    |    117,927 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 116,867 of 117,927    |
|    dxf to albert@spenarnc.xs4all.nl    |
|    Re: Reverse SCAN SPLIT    |
|    10 Oct 24 20:57:43    |
   
   From: dxforth@gmail.com   
      
   On 10/10/2024 7:00 pm, albert@spenarnc.xs4all.nl wrote:   
   > In article <5c65a8f1fdfc3e9937a825842fe23dc2758f48ef@i2pn2.org>,   
   > dxf 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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca