New Release 93

General:. This page generally describes new functionality in the 93 series of revisions and uploads. This is Working Documentation that with maturity will be moved to the Master Documentation.

This revision introduces another container class: #dict: Dictionary. The dictionary object is implemented as a Red-Black tree. At each node there is a key and a value. In this implementation, the key and value may be most GLEE objects (i.e. string, numeric, sequence, clock). The conformity rules are more strict than the rest of GLEE. If the number of key elements is 1, the value is stored for that key. If the number value elements is one, the value is stored for each key element. If the number of value elements and key elements are the same, the storage is by one-to-one correspondence. Otherwise, a conformity error results. The examples do better than words to show the usage.

Indexing data out of a dictionary returns a sequence with items corresponding to keys used in indexing. If the key is not found, the respective result item is "no value". Even if just one key is used, the result is a sequence, albeit 1 element. You use disclose (<) to obtain the actual object.

There is lots of work to do on the dictionary object. As GLEE matures, this object will do much of the work people lean on SQL for. For this to happen, I need to make it persistent. I also need to develop the syntax and operators to request things like joins of two or more dictionaries. It will be fun.

Simple Dictionary (#dict):. The index or key to a dictionary object may be most GLEE objects (e.g. string, numeric, clock, sequence). The value is assigned into the dictionary at the key position in the same way you would assign items into a sequence or elements into a numeric or string vector. If the key is not found, a NV (non-value) object is returned. This is the same behavior we get from using an undefined symbol in a namespace. Notice that a sequence is always returned, even if just one key is given. This is because more than one key could have been given and we don't want a discontinuity between 1 and 2 keys (i.e. not sequence for 1; sequence for 2 or greater).

Without: (#dict ~ key):. This is a slight departure from the prevailing style of GLEE. The without ( ~ ) operator generally makes a copy; removes the item(s) from the copy; and returns the copy. For a dictionary, this isn't appropriate (the persistent form of the object could contain a huge number of elements). So for dictionaries, unless I later adopt separate syntax for inplace vs. copy removal, without operates on the inplace object. This operator does return the affected object however.

Vector populating:. This example illustrates populating a dictionary with a vector. In this example I create keys from 1000 random numbers ... there are duplicates. I use the key as the value. I populate the dictionary and then read out its contents by the vector of keys. I verify the two are identical by adding them up.

:seq :. Return dictionary as a sequence. The result is a sequence containing two element sequences in each item. The first element is the key. The second element is the value. This is principally a debugging aid. The value element is always a sequence. This is because some of the other objects in this collection class family (e.g. #Bag and #Idx) may have more than one value element for a given key. I wanted the nesting of elements in all objects of the collection family to be consistent.