Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0004/dictionary.tty
There are no other files named dictionary.tty in the archive.
DICTIONARY - name lookup and completion

This file contains routines for the creation of attribute value dictionaries which may be use in
name completion.  I.e. if the word "Interlisp" is the only word in a dictionary whose first three
letters are "int", then it will a trivial task using the dictionary in this package to efficiently
complete the test to "interlisp".  If the word "interpret" also happened to be in the dictionary,
then the dictionary could be used to complet the test to "inter" and retrieve a subdictionary of
the words starting with just those five letters.

The package deals with and manipulates objects called dictionaries.  Dictionaries may be created
with the function
	CREATEDICTIONARY[ENTRYLST]
Each entry in ENTRYLST may either be a string (or a atom name) of an expression whose CAR
is a string (of atom name) and whose CDR is value to be associated with that string.  In essense,
each entry specifies an entry name and an entry value.  If the entry value is unspecified (only a
string or atom name is used as the entry) then T is used.  The entry name will never actually
appear in the dictionary, but is used to define the path through the dictionary where the entry
value is located.

Once a dictionary has been created, new entries may be added to it with the function
	ADDTODICTIONARY[ENTRY, DICT]
where ENTRY is in the form describe above.  ADDTODICTIONARY returns a dictionary.  Note
that this function is destructive to DICT but may change the top level data structure of the
dictionary.  Thus the result of this operation may or may not be EQ to the original dictionary.

A dcitionary may be searched with the function
	FINDINDICTIONARY[STRING, DICTIONARY]
This will return the subdictionary of DICTIONARY of those entries whose initials characters match
STRING.  If no entry in DICTIONARY matches STRING, then NIL is returned.  If only one
entry is DICTIONARY matches STRING, then that entry is returned as a dictionary with only
one entry.  The completion string and the entry value may easily be obtained by the access
described below.  If many entries match STRING, then a subdictionary containing all those entries
is returned.  Note that the entries in the resulting subdictionary will have had their initial 
characters (those matching STRING) stripped away.  Thus if "interlisp" and "intepret" are the only
two entries in the dictionary whose first three letters are "int" then the value of
	(FINDINDICTIONARY "INT" DICTIONARY)
will effectively be a dictionary containing the two entries "erlisp" and "epret".

All of the entries in a dictionary may be obtained by
	(LISTDICTIONARY DICT PREFIX)
The result will be a list of dotted pairs -  (EntryName . EntryValue) - If PREFIX is present then
it will be put in as a prefix to all entry names.

ACCESS FUNCTIONS:
	NUMOFENTRIES[DICT] will return the number of entries in the dictionary DICT.
	GETCOMPLETIONSTRING[DICT] will return that string which is the common initial string
of all entries in the dictionary DICT.
	GETTOPENTRY[DICT] will return the entry value of entry in the dictionary DICT whose
entry name is exactly GETCOMPLETIONSTRING[DICT] is such an entry exists.  If no such entry
exists, then NIL will be returned.  Note that if DICT contains exactly one entry, then this function
is guaranteed to return a non-nil result.
	GETTOPENTRY[DICT] will return the entry value of entry in the dictionary DICT whose
entry name is exactly GETCOMPLETIONSTRING[DICT] is such an entry exists.  If no such entry
exists, then NIL will be returned.  Note that if DICT contains exactly one entry, then this function
is guaranteed to return a non-nil result.