Skip to main content

Ordered Trees

The animation illustrates the effect of a series of Set commands. It starts out by setting (unsubscripted) A = 4. ObjectScript reserves a memory location for A, and stores 4. By the way, all the locations in this example are set to 4; this is an arbitrary choice. Don't pay attention to the 4; pay attention to the tree built by these statements.

The next three statements store 4 in several array locations (5, 9, 7) (A can be both a scalar and an array). Notice how these locations are shown as a new level or dimension in the tree, and that they are sorted based on the subscript value, regardless of the order of the statements. At this point, a traditional array would need (at least) nine reserved memory locations, but so far A only uses four. The next two statements use negative integer subscripts. Traditional arrays may not allow this, but in ObjectScript they have a spot in the ordered tree that makes sense. Next, you see two Set statements that use real number, fractional subscripts. Again, this only makes sense in an ordered tree.

The animation continues by setting three array locations using non-numeric subscripts. All non-numeric locations sort to the right of numeric locations, but the non-numerics sort alphabetically. So far, the A array only has one dimension. The next three statements create a second dimension, which is also sorted. The last statement creates a third dimension.

FeedbackOpens in a new tab