Autocomplete

Autocomplete[{"string1","string2",},"string"]

gives a list of the stringi that can complete string.

Autocomplete["s1"w1,"s2"w2,,"string"]

puts the completions in order of decreasing weights wi.

Autocomplete[{assoc1,assoc2,},"string"]

uses completions specified by the associations associ.

Autocomplete[comps,"string",n]

gives the first at most n completions.

Autocomplete[comps]

gives an AutocompletionFunction[] that can be applied to a string.

Details

  • In the form Autocomplete[{assoc1,}], possible elements in the associ include:
  • "Result"the result to return
    "String"the complete string
    "Weight"weight used to sort completions

Examples

Basic Examples  (2)

Create an AutocompletionFunction from a list of words:

Apply the function to a string:

Limit the number of results:

Perform the above operations in a single step:

Words can be assigned weights:

When only "String" and "Weight" are used, it is possible to use a more compact form:

If the key "Result" is present, the resulting string will be modified accordingly:

Fields do not always have to be specified:

Introduced in 2015
 (10.2)