--- /dev/null
+
+USING: assocs kernel tools.completion tools.completion.private
+tools.test ;
+
+IN: tools.completion
+
+[ f ] [ "abc" "def" fuzzy ] unit-test
+[ V{ 4 5 6 } ] [ "set-nth" "nth" fuzzy ] unit-test
+
+[ V{ V{ 0 } V{ 4 5 6 } } ] [ V{ 0 4 5 6 } runs ] unit-test
+
+[ { "nth" "?nth" "set-nth" } ] [
+ "nth" { "set-nth" "nth" "?nth" } dup zip completions keys
+] unit-test
rot [ ch>lower ] [ ch>upper ] bi
[ eq? ] bi-curry@ [ bi or ] 2curry find-from drop ;
+PRIVATE>
+
:: (fuzzy) ( accum i full ch -- accum i full ? )
ch i full smart-index-from [
:> i i accum push
: completion, ( short candidate -- )
completion dup first 0 > [ , ] [ drop ] if ;
-PRIVATE>
-
: completions ( short candidates -- seq )
[ ] [
[ [ completion, ] with each ] { } make