Name

scan:toolbelt — ordinary primitive

Synopsis

FORTH
SCAN ( str len char -- str+i len-i )(); 
 ;

Description

Look for a particular character in the specified string.

 : SCAN     
    >R  BEGIN  DUP WHILE  OVER C@ R@ -
        WHILE  1 /STRING  REPEAT THEN
    R> DROP ;

ie. scan for first occurence of c in string

   : SCAN >R BEGIN DUP OVER C@ R@ = 0= OR WHILE 
                    1- SWAP 1- SWAP REPEAT R> DROP ;