-
-
Save lsparrish/485480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable this | |
variable that | |
: chain create here !that 0 , here !this 2 allot ; | |
: +link here push @this , @last , pop !this @@last !last ; | |
: seal @this @that ! ; | |
variable flag | |
variable xt | |
variable str | |
: zdrop ( n-n | nz-z ) dup 0 =if 2drop 0 then ; | |
: (search) ( a-fa ) | |
repeat | |
@ 0; dup 1+ @ zdrop 0; | |
d->name @str compare if flag on dup 1+ @ zdrop 0; d->xt @ !xt drop ;then | |
again ; | |
: search-chain ( a$- ) | |
!str 0 !xt 0 !flag | |
(search) @xt @flag ; | |
( ~~~~~~~~~~~~~~~~~~~~~~ TEST STUFF ~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
: walk ( a- ) repeat @ 0; dup 1+ @ zdrop 0; d->name type space again ; | |
chain oo | |
: foo 1 . ; +link | |
: bar 1 . ; +link | |
: biz 1 . ; +link | |
: bag 1 . ; +link | |
seal | |
oo walk | |
oo " bar" search-chain .s reset | |
oo " zdabar" search-chain .s reset | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment