home bbs files messages ]

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,865 of 117,927   
   dxf to dxf   
   Re: Reverse SCAN SPLIT   
   10 Oct 24 17:00:43   
   
   From: dxforth@gmail.com   
      
   On 7/10/2024 7:52 pm, 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 ;   
      
   Cleaned-up version:   
      
   : SCAN< ( a u c -- a2 u2 | a 0 )   
     >r begin dup while \char r@ = until 1+ then r> drop ;   
      
   > \ 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 ;   
      
   --- 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