d09a03ddca
FossilOrigin-Name: a5d4a3564e05d167ca72a87be254464c786f923048b262c645d8cb11b1a720a9
16 lines
388 B
Forth
16 lines
388 B
Forth
If you want to tokenize a string into a set, this is one approach.
|
|
|
|
~~~
|
|
{{
|
|
'Split-On var
|
|
:match? (c-f) @Split-On eq? ;
|
|
:terminate (s-s) #0 over n:dec store ;
|
|
:step (ss-s) [ n:inc ] dip match? [ dup , terminate ] if ;
|
|
---reveal---
|
|
:s:tokenize (sc-a)
|
|
!Split-On s:keep
|
|
here #0 , [ dup , dup [ step ] s:for-each drop ] dip
|
|
here over - n:dec over store ;
|
|
}}
|
|
~~~
|
|
|