Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created July 18, 2010 17:23
Show Gist options
  • Save lsparrish/480553 to your computer and use it in GitHub Desktop.
Save lsparrish/480553 to your computer and use it in GitHub Desktop.
( cd -- char dict )
( cdl -- cd last )
( cdn -- cd new )
( cdf -- cd find )
( cde -- cd exec )
( cdk -- cd key )
vocab cd ((
variable cdl
: cdn ( "- ) 32 accept here @cdl , @tib , !cdl ] ;
: cdf ( c-af ) cdl repeat @ 2dup 1+ @ =if nip 2 + -1 ;then dup 0; drop again ;
: cde ( c- ) cdf if .word ;then drop ;
: cdk ( "- ) key cde ;
))
variable c
: advance2 ( $c-$f ) !c repeat @+ dup 0; drop @c =if dup 1- 0 !swap -1 ;then again ;
: process ( $c- ) advance2 if @c cde ;then drop ;
: 2process ( $c- ) push dup pop process ;
cdn . type ;
: bar 10 ;
: baz 20 ;
: foo s" bar.baz" '. process2 ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment