Previous Up Next

14.4.1  Tables

A table is a map (associative container) used to store information associated to indices which are much more general than integers, such as strings or sequences. For example, use one to store a table of phone numbers indexed by names.

In Xcas, the indices in a table may be any kind of Xcas objects. Access is done by a binary search algorithm, where the sorting function first sorts by type and then uses an order for each type (e.g. < for numeric types, lexicographic order for strings, etc.)

The table command creates a table.

Tables can also be created and the elements of a table can be changed by using the := assignment.

Example

T:=table(3=-10,"a"=10,"b"=20,"c"=30,"d"=40):;
T["b"]
     
20           
T[3]
     
−10           
T[3]:=-15:; T[3]
     
−15           

Previous Up Next