Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created July 21, 2010 03:20
Show Gist options
  • Save lsparrish/484007 to your computer and use it in GitHub Desktop.
Save lsparrish/484007 to your computer and use it in GitHub Desktop.
( char dictionary )
variable cdl
: cdn ( "- ) 32 accept here @cdl , @tib , !cdl -1 , ] ;
: cdf ( c-af ) cdl repeat @ 2dup 1+ @ =if nip 3 + -1 ;then dup 0; drop again ;
: cde ( c- ) cdf if dup 1- @ 0 =if drop ;then execute ;then drop ;
: cda ( c- ) cdf if 1- on ;then '? emit ;
: cdd ( c- ) cdf if 1- off ;then '? emit ;
( keep tib string )
: kts tib here over getLength 1+ dup allot copy ;
( accept input, test each char )
tib variable: t
variable del
: t, ( n- ) !@t t ++ ;
: zt ( - ) 0 t, tib !t ;
: accept ( n"- ) !del
repeat key dup emit
dup cde
dup @del =if zt drop ;then
t, again ;
cdn : kts drop 32 ;
: foo 32 accept tib type ;
foo test:
': cdd ( deactivate )
foo test:
': cda ( activate )
foo test:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment