Skip to content

Instantly share code, notes, and snippets.

@foucist
Forked from crcx/gist:575177
Created September 11, 2010 18:25
Show Gist options
  • Save foucist/575421 to your computer and use it in GitHub Desktop.
Save foucist/575421 to your computer and use it in GitHub Desktop.
better word names?
with quotes'
( compare two strings from the beginning and return how many )
( similar characters there are before the strings diverge. )
: ^match ( $$-n )
0 -rot repeat @+ [ swap @+ ] dip =if rot 1+ -rot else 2drop ;then again ;
( test each word in the dictionary for similarity. if similar up )
( to the current point, add to the suggestions queue. )
create list here , 100 allot
: to_list ( n- ) list ++ @list ! ;
: from_list ( -n ) @list @ list -- ;
: list.size ( -n ) @list list - ;
create tp here , 100 allot
: tib tp 1+ ;
: buffer.reset tp !tp 0 !tib ;
: buffer.add_to tp ++ @tp ! 0 @tp 1+ ! ;
: get_list
last repeat @ 0;
tib over d->name
^match tib getLength =if dup to_list then
again ;
: show_list repeat list.size 0; drop from_list d->name type space again ;
variable delim
: delim? ( n-n ) dup @delim = [ drop 0 ] if ;
: isTab? ( n-nf ) dup 27 = [ drop -1 get_list show_list tib type ] [ 0 ] if ;
: accept
buffer.reset !delim
repeat key isTab? 0 =if delim? 0; dup emit buffer.add_to then again ;
32 accept
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment